diff --git a/CHANGES.rst b/CHANGES.rst index db330acf..7c24e28a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,15 @@ Changelog 3.6.1 (unreleased) ------------------ -- Nothing changed yet. +- Fix some confusion in setup.py classifiers and depenencies due to introduction of Plone 5.2 support. + Introduces plone.is_plone5.2 variable. + [jensens] + +- Fix behavior template: use separate marker interface, + register marker in the behavior zcml and adapt content to the marker, not to IDexterityContent. + For further reference, see the plone.behavior README.rst Example 2. + Fixes #16. + [fredvd, jensens] 3.6.0 (2019-02-25) diff --git a/bobtemplates/plone/addon/setup.py.bob b/bobtemplates/plone/addon/setup.py.bob index 1d6f48ba..1f4677ab 100644 --- a/bobtemplates/plone/addon/setup.py.bob +++ b/bobtemplates/plone/addon/setup.py.bob @@ -21,15 +21,25 @@ setup( classifiers=[ "Environment :: Web Environment", "Framework :: Plone", + "Framework :: Plone :: Addon", {{% if not plone.is_plone5 %}} "Framework :: Plone :: 4.3", {{% endif %}} {{% if plone.is_plone5 %}} "Framework :: Plone :: 5.0", +{{% endif %}} +{{% if plone.is_plone51 %}} "Framework :: Plone :: 5.1", +{{% endif %}} +{{% if plone.is_plone52 %}} + "Framework :: Plone :: 5.2", {{% endif %}} "Programming Language :: Python", "Programming Language :: Python :: 2.7", +{{% if plone.is_plone52 %}} + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", +{{% endif %}} "Operating System :: OS Independent", "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", ], @@ -44,11 +54,15 @@ setup( include_package_data=True, zip_safe=False, install_requires=[ - # -*- Extra requirements: -*- - 'plone.api>=1.8.4', - 'Products.GenericSetup>=1.8.2', 'setuptools', + # -*- Extra requirements: -*- 'z3c.jbot', +{{% if not (plone.is_plone51 or plone.is_plone52 %}} + 'Products.GenericSetup>=1.8.2', +{{% endif %}} +{{% if not plone.is_plone52 %}} + 'plone.api>=1.8.4', +{{% endif %}} {{% if not plone.is_plone5 %}} 'plone.app.dexterity<=2.1.1', 'plone.app.referenceablebehavior', @@ -60,10 +74,12 @@ setup( extras_require={ 'test': [ 'plone.app.testing', +{{% if not plone.is_plone52 %}} # Plone KGS does not use this version, because it would break # Remove if your package shall be part of coredev. # plone_coredev tests as of 2016-04-01. 'plone.testing>=5.0.0', +{{% endif %}} {{% if plone.is_plone5 %}} 'plone.app.contenttypes', {{% endif %}} diff --git a/bobtemplates/plone/addon/src/+package.namespace+/+package.name+/tests/test_setup.py.bob b/bobtemplates/plone/addon/src/+package.namespace+/+package.name+/tests/test_setup.py.bob index c61d7c53..566eb790 100644 --- a/bobtemplates/plone/addon/src/+package.namespace+/+package.name+/tests/test_setup.py.bob +++ b/bobtemplates/plone/addon/src/+package.namespace+/+package.name+/tests/test_setup.py.bob @@ -19,7 +19,7 @@ class TestSetup(unittest.TestCase): def setUp(self): """Custom shared utility setup for tests.""" self.portal = self.layer['portal'] -{{% if plone.is_plone51 %}} +{{% if plone.is_plone51 or plone.is_plone52 %}} self.installer = get_installer(self.portal, self.layer['request']) {{% else %}} self.installer = api.portal.get_tool('portal_quickinstaller') @@ -27,7 +27,7 @@ class TestSetup(unittest.TestCase): def test_product_installed(self): """Test if {{{ package.dottedname }}} is installed.""" -{{% if plone.is_plone51 %}} +{{% if plone.is_plone51 or plone.is_plone52 %}} self.assertTrue(self.installer.is_product_installed( '{{{ package.dottedname }}}')) {{% else %}} @@ -51,14 +51,14 @@ class TestUninstall(unittest.TestCase): def setUp(self): self.portal = self.layer['portal'] -{{% if plone.is_plone51 %}} +{{% if plone.is_plone51 or plone.is_plone52 %}} self.installer = get_installer(self.portal, self.layer['request']) {{% else %}} self.installer = api.portal.get_tool('portal_quickinstaller') {{% endif %}} roles_before = api.user.get_roles(TEST_USER_ID) setRoles(self.portal, TEST_USER_ID, ['Manager']) -{{% if plone.is_plone51 %}} +{{% if plone.is_plone51 or plone.is_plone52 %}} self.installer.uninstall_product('{{{ package.dottedname }}}') {{% else %}} self.installer.uninstallProducts(['{{{ package.dottedname }}}']) @@ -67,7 +67,7 @@ class TestUninstall(unittest.TestCase): def test_product_uninstalled(self): """Test if {{{ package.dottedname }}} is cleanly uninstalled.""" -{{% if plone.is_plone51 %}} +{{% if plone.is_plone51 or plone.is_plone52 %}} self.assertFalse(self.installer.is_product_installed( '{{{ package.dottedname }}}')) {{% else %}} diff --git a/bobtemplates/plone/base.py b/bobtemplates/plone/base.py index ab85320f..8e617e0c 100644 --- a/bobtemplates/plone/base.py +++ b/bobtemplates/plone/base.py @@ -240,16 +240,13 @@ def set_plone_version_variables(configurator, answer=None): return if 'plone.is_plone5' not in configurator.variables: # Find out if it is supposed to be Plone 5. - if version.startswith('5'): - configurator.variables['plone.is_plone5'] = True - else: - configurator.variables['plone.is_plone5'] = False + configurator.variables['plone.is_plone5'] = version.startswith('5') if 'plone.is_plone51' not in configurator.variables: # Find out if it is supposed to be Plone 5.1 or higher - if version.startswith('5.1') or version.startswith('5.2'): - configurator.variables['plone.is_plone51'] = True - else: - configurator.variables['plone.is_plone51'] = False + configurator.variables['plone.is_plone51'] = version.startswith('5.1') + if 'plone.is_plone52' not in configurator.variables: + # Find out if it is supposed to be Plone 5.2 or higher + configurator.variables['plone.is_plone52'] = version.startswith('5.2') if 'plone.minor_version' not in configurator.variables: # extract minor version (4.3) # (according to https://plone.org/support/version-support-policy) diff --git a/bobtemplates/plone/behavior.py b/bobtemplates/plone/behavior.py index 98bae67c..efc51f10 100644 --- a/bobtemplates/plone/behavior.py +++ b/bobtemplates/plone/behavior.py @@ -70,7 +70,7 @@ def _update_behaviors_configure_zcml(configurator): description="{description}" provides=".{normalized_name}.I{klass_name}" factory=".{normalized_name}.{klass_name}" - marker=".{normalized_name}.I{klass_name}" + marker=".{normalized_name}.I{klass_name}Marker" /> """.format( diff --git a/bobtemplates/plone/behavior/behaviors/+behavior_name_normalized+.py.bob b/bobtemplates/plone/behavior/behaviors/+behavior_name_normalized+.py.bob index 3e0b5112..5c2b000b 100644 --- a/bobtemplates/plone/behavior/behaviors/+behavior_name_normalized+.py.bob +++ b/bobtemplates/plone/behavior/behaviors/+behavior_name_normalized+.py.bob @@ -10,6 +10,9 @@ from zope.interface import implementer from zope.interface import provider +class I{{{behavior_name_klass}}}Marker: + pass + @provider(IFormFieldProvider) class I{{{behavior_name_klass}}}(model.Schema): """ @@ -23,7 +26,7 @@ class I{{{behavior_name_klass}}}(model.Schema): @implementer(I{{{behavior_name_klass}}}) -@adapter(IDexterityContent) +@adapter(I{{{behavior_name_klass}}}Marker) class {{{behavior_name_klass}}}(object): def __init__(self, context): self.context = context diff --git a/package-tests/test_base.py b/package-tests/test_base.py index a9b0c54d..e836d7bd 100644 --- a/package-tests/test_base.py +++ b/package-tests/test_base.py @@ -105,6 +105,20 @@ def test_set_plone_version_variables(tmpdir): base.set_plone_version_variables(configurator) assert configurator.variables.get('plone.is_plone5') assert not configurator.variables.get('plone.is_plone51') + assert not configurator.variables.get('plone.is_plone52') + assert configurator.variables.get('plone.minor_version') == '5' + + configurator = Configurator( + template='bobtemplates.plone:addon', + target_directory=target_dir, + variables={ + 'plone.version': '5.2', + }, + ) + base.set_plone_version_variables(configurator) + assert configurator.variables.get('plone.is_plone5') + assert not configurator.variables.get('plone.is_plone51') + assert not configurator.variables.get('plone.is_plone52') assert configurator.variables.get('plone.minor_version') == '5' configurator = Configurator( @@ -117,6 +131,7 @@ def test_set_plone_version_variables(tmpdir): base.set_plone_version_variables(configurator) assert configurator.variables.get('plone.is_plone5') assert configurator.variables.get('plone.is_plone51') + assert not configurator.variables.get('plone.is_plone52') assert configurator.variables.get('plone.minor_version') == '5.1' configurator = Configurator( @@ -129,6 +144,7 @@ def test_set_plone_version_variables(tmpdir): base.set_plone_version_variables(configurator) assert not configurator.variables.get('plone.is_plone5') assert not configurator.variables.get('plone.is_plone51') + assert not configurator.variables.get('plone.is_plone52') assert configurator.variables.get('plone.minor_version') == '4.3'