Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
1.12.1 (unreleased)
===================

- Nothing changed yet.

- Add compatability with Plone 6.1 and 6.2 with plone.distribution.
[pbauer]

1.12.0 (2021-03-06)
===================
Expand Down
44 changes: 31 additions & 13 deletions collective/recipe/plonesite/plonesite.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ class LinkIntegrityNotificationException(Exception):
except ImportError:
upgrade = None

HAVE_DISTRIBUTIONS = True
try:
from plone.distribution.api import site
from Products.CMFPlone.factory import addPloneSite
from Products.CMFPlone.factory import _DEFAULT_PROFILE
except ImportError:
HAVE_DISTRIBUTIONS = False

logger = logging.getLogger('collective.recipe.plonesite')

Expand Down Expand Up @@ -112,19 +119,30 @@ def create(
if site_id not in oids:
created = True
if has_setup_content():
# we have to simulate the new zmi admin screen here - at
# least provide:
# extension_ids
# setup_content (plone default is currently 'true')
container.REQUEST.form.update({
'form.submitted': True,
'site_id': site_id,
'setup_content': False,
'default_language': default_language})
form = container.restrictedTraverse('@@plone-addsite')
# Skip the template rendering
form.index = lambda: None
form()
if HAVE_DISTRIBUTIONS:
payload = {
"title": "Plone",
"profile_id": _DEFAULT_PROFILE,
"distribution_name": "classic",
"setup_content": False,
"default_language": default_language,
"portal_timezone": "UTC",
}
addPloneSite(container, site_id, **payload)
else:
# we have to simulate the zmi admin screen here - at
# least provide:
# extension_ids
# setup_content (plone default is currently 'true')
container.REQUEST.form.update({
'form.submitted': True,
'site_id': site_id,
'setup_content': False,
'default_language': default_language})
form = container.restrictedTraverse('@@plone-addsite')
# Skip the template rendering
form.index = lambda: None
form()
else:
factory = container.manage_addProduct['CMFPlone']
factory.addPloneSite(site_id, create_userfolder=1)
Expand Down