From 5723cc2afc24f9f7cdae00bfb1ec32d156d6b438 Mon Sep 17 00:00:00 2001 From: Fred van Dijk Date: Wed, 27 Feb 2019 17:54:45 +0100 Subject: [PATCH] Fix behavior template: use separate marker interface. Register marker in the behavior zcml and adapt content to the marker. --- CHANGES.rst | 5 ++++- bobtemplates/plone/behavior.py | 2 +- .../behavior/behaviors/+behavior_name_normalized+.py.bob | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index db330acf..d88fa1ff 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,10 @@ Changelog 3.6.1 (unreleased) ------------------ -- Nothing changed yet. +- 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/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