Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix site creation script for Plone 6.1 #100

Merged
merged 1 commit into from
Nov 7, 2024
Merged
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
11 changes: 7 additions & 4 deletions backend_addon/cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
"author": "Plone Community",
"email": "[email protected]",
"github_organization": "collective",
"use_prerelease_versions": "{{ 'No' | use_prerelease_versions }}",
"plone_version": "{{ cookiecutter.use_prerelease_versions | latest_plone }}",
"python_package_name": "{{ cookiecutter.github_organization|lower }}.{{ cookiecutter.title|replace(' ', '')|replace('-', '_')|replace('.', '')|lower }}",
"feature_headless": [
"1",
"0"
],
"feature_headless": ["1", "0"],
"__feature_headless": "{{ cookiecutter.feature_headless }}",
"__feature_distribution": "0",
"__package_name": "{{ cookiecutter.python_package_name | package_name }}",
Expand All @@ -26,6 +25,8 @@
"title": "Addon Title",
"description": "A short description of your addon",
"github_organization": "GitHub Username or Organization",
"use_prerelease_versions": "Should we use prerelease versions?",
"plone_version": "Plone Version",
"python_package_name": "Python package name",
"author": "Author",
"email": "Author E-mail",
Expand All @@ -37,6 +38,8 @@
},
"_copy_without_render": [],
"_extensions": [
"cookieplone.filters.latest_plone",
"cookieplone.filters.use_prerelease_versions",
"cookieplone.filters.pascal_case",
"cookieplone.filters.package_name",
"cookieplone.filters.package_namespace"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-c https://dist.plone.org/release/6.0-latest/constraints.txt
-c https://dist.plone.org/release/{{ cookiecutter.plone_version }}/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from {{ cookiecutter.python_package_name }}.interfaces import IBrowserLayer
from Products.CMFPlone.factory import _DEFAULT_PROFILE
from Products.CMFPlone.factory import addPloneSite
from Products.GenericSetup.tool import SetupTool
from Testing.makerequest import makerequest
from zope.interface import directlyProvidedBy
from zope.interface import directlyProvides
Expand Down Expand Up @@ -43,9 +44,12 @@ def asbool(s):
payload = {
"title": "{{ cookiecutter.title }}",
"profile_id": _DEFAULT_PROFILE,
"extension_ids": [
"{{ cookiecutter.python_package_name }}:default",
],
{% if cookiecutter.plone_version >= "6.1" and cookiecutter.__feature_headless == "0" -%}
"distribution_name": "classic",
{%- endif %}
{% if cookiecutter.plone_version >= "6.1" and cookiecutter.__feature_headless == "1" -%}
"distribution_name": "default",
{%- endif %}
"setup_content": False,
"default_language": "{{ cookiecutter.__profile_language }}",
"portal_timezone": "UTC",
Expand All @@ -59,4 +63,7 @@ def asbool(s):
if site_id not in app.objectIds():
site = addPloneSite(app, site_id, **payload)
transaction.commit()
app._p_jar.sync()

portal_setup: SetupTool = site.portal_setup
portal_setup.runAllImportStepsFromProfile("profile-{{ cookiecutter.python_package_name }}:default")
transaction.commit()
6 changes: 5 additions & 1 deletion backend_addon/{{ cookiecutter.__folder_name }}/setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Installer for the {{ cookiecutter.python_package_name }} package."""

from pathlib import Path
from setuptools import find_packages
from setuptools import setup
Expand Down Expand Up @@ -55,7 +56,7 @@
"setuptools",
"Products.CMFPlone",
"plone.api",
{%- if cookiecutter.__feature_headless == '1' %}
{% if cookiecutter.__feature_headless == '1' -%}
"plone.restapi",
"plone.volto",
{%- endif %}
Expand All @@ -65,6 +66,9 @@
"zest.releaser[recommended]",
"zestreleaser.towncrier",
"plone.app.testing",
{% if cookiecutter.__feature_headless == "0" and cookiecutter.plone_version >= "6.1" -%}
"plone.classicui",
{%- endif -%}
"plone.restapi[test]",
"pytest",
"pytest-cov",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def asbool(s):
payload = {
"title": "{{ cookiecutter.title }}",
"profile_id": _DEFAULT_PROFILE,
"extension_ids": [
"{{ cookiecutter.python_package_name }}:default",
],
{% if cookiecutter.plone_version >= "6.1" %}
"distribution_name": "default",
{% endif %}
"setup_content": False,
"default_language": "{{ cookiecutter.__profile_language }}",
"portal_timezone": "UTC",
Expand All @@ -61,8 +61,12 @@ def asbool(s):
if site_id not in app.objectIds():
site = addPloneSite(app, site_id, **payload)
transaction.commit()

portal_setup: SetupTool = site.portal_setup
portal_setup.runAllImportStepsFromProfile("profile-{{ cookiecutter.python_package_name }}:default")
transaction.commit()

if EXAMPLE_CONTENT:
portal_setup: SetupTool = site.portal_setup
portal_setup.runAllImportStepsFromProfile("{{ cookiecutter.python_package_name }}:initial")
portal_setup.runAllImportStepsFromProfile("profile-{{ cookiecutter.python_package_name }}:initial")
transaction.commit()
app._p_jar.sync()