-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add plone domain to enable site creation
- Loading branch information
Showing
8 changed files
with
197 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from AccessControl.SecurityManagement import newSecurityManager | ||
from plone.distribution.api.site import create | ||
from Products.CMFPlone.factory import _DEFAULT_PROFILE | ||
from Testing.makerequest import makerequest | ||
|
||
import os | ||
import transaction | ||
|
||
|
||
TRUTHY = frozenset(("t", "true", "y", "yes", "on", "1")) | ||
|
||
|
||
def asbool(value: str|bool|None) -> bool: | ||
"""Return the boolean value ``True`` if the case-lowered value of string | ||
input ``s`` is a :term:`truthy string`. If ``s`` is already one of the | ||
boolean values ``True`` or ``False``, return it. | ||
""" | ||
if value is None: | ||
return False | ||
if isinstance(value, bool): | ||
return value | ||
return value.strip().lower() in TRUTHY | ||
|
||
|
||
DELETE_EXISTING = asbool(os.getenv("DELETE_EXISTING")) | ||
|
||
|
||
app = makerequest(globals()["app"]) | ||
admin = app.acl_users.getUserById("admin") | ||
newSecurityManager(None, admin.__of__(app.acl_users)) | ||
|
||
config = { | ||
{% for key, value in site.items() %} | ||
{% if key == "extension_ids" %} | ||
{% for extension_id in value %} | ||
"extension_ids": [ | ||
"{{ extension_id }}", | ||
], | ||
{% endfor %} | ||
{% else %} | ||
"{{ key }}": "{{ value }}", | ||
{% endif %} | ||
{% endfor %} | ||
"profile_id": _DEFAULT_PROFILE, | ||
} | ||
|
||
if config["site_id"] in app.objectIds() and DELETE_EXISTING: | ||
app.manage_delObjects([config["site_id"]]) | ||
transaction.commit() | ||
app._p_jar.sync() | ||
|
||
if config["site_id"] not in app.objectIds(): | ||
site = create(app, "{{ distribution }}", config) | ||
transaction.commit() | ||
app._p_jar.sync() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#:[plone] | ||
#:title = plone | ||
#:description = Plone application related | ||
#:depends = applications.zope | ||
#:[target.plone-createsite] | ||
#:description = Creates a Plone site using the script provided in `PLONE_CREATESITE_SCRIPT` configuration. | ||
#: | ||
#:[setting.PLONE_CREATESITE_SCRIPT] | ||
#:description = Path to the script to create a Plone site | ||
#:default = .mxmake/files/plone-createsite.py | ||
#: | ||
#:[target.plone-createsite-dirty] | ||
#:description = Touches the sentinel file to force a rebuild of the Plone instance. This will not touch the database. | ||
#: | ||
#:[target.plone-createsite-clean] | ||
#:description = Removes the sentinel file to force files but keeps Plone database. | ||
#: | ||
#:[target.plone-createsite-purge] | ||
#:description = Removes the Plone instance from the database, but the database itself is kept. | ||
|
||
|
||
############################################################################## | ||
# plone | ||
############################################################################## | ||
|
||
PLONE_CREATESITE_SENTINEL:=$(SENTINEL_FOLDER)/plone-createsite.sentinel | ||
|
||
PLONE_CREATESITE_TARGET: $(FILES_TARGET) $(ZOPE_RUN_TARGET) | ||
|
||
.PHONY: plone-createsite | ||
plone-createsite: PLONE_CREATESITE_TARGET | ||
@echo "Creating Plone Site" | ||
@touch $(PLONE_CREATESITE_SENTINEL) | ||
@zconsole run $(ZOPE_INSTANCE_FOLDER)/etc/zope.conf $(PLONE_CREATESITE_SCRIPT) | ||
|
||
.PHONY: plone-createsite-dirty | ||
plone-createsite-dirty: | ||
@touch $(PLONE_CREATESITE_SENTINEL) | ||
|
||
.PHONY: plone-createsite-clean | ||
plone-createsite-clean: | ||
@touch $(PLONE_CREATESITE_SENTINEL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters