Skip to content

Commit

Permalink
Get distribution name from report, not from the answers (#62)
Browse files Browse the repository at this point in the history
* Get the name of the existing distribution from the report, not the answers (Fix #60)

* Use the new format for cookiecutter-zope-instance
  • Loading branch information
ericof authored Apr 20, 2024
1 parent a012075 commit 14bfc56
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions instance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ default_context:
initial_user_name: 'admin'
initial_user_password: 'admin'

load_zcml:
package_includes: ['plone.distribution']
zcml_package_includes: ['plone.distribution']

db_storage: direct
1 change: 1 addition & 0 deletions news/60.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Get the name of the existing distribution from the report, not the answers [@ericof]
5 changes: 3 additions & 2 deletions src/plone/distribution/api/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from plone.distribution.registry import DistributionRegistry
from Products.CMFPlone.Portal import PloneSite
from typing import List
from typing import Optional
from typing import Union
from zope.annotation.interfaces import IAnnotations

Expand Down Expand Up @@ -82,13 +83,13 @@ def get_creation_report(site: PloneSite) -> Union[SiteCreationReport, None]:
return annotations.get(SITE_REPORT_ANNO, None)


def get_current_distribution(site: PloneSite = None) -> Distribution:
def get_current_distribution(site: PloneSite = None) -> Optional[Distribution]:
"""Get the distribution used to create the current site."""
if site is None:
site = api.portal.get()
creation_report = get_creation_report(site)
dist = None
if creation_report:
name = creation_report.answers.get("distribution", "")
name = creation_report.name or creation_report.answers.get("distribution", "")
dist = get(name=name)
return dist

0 comments on commit 14bfc56

Please sign in to comment.