src/pyams_portal/template.py
changeset 252 6cd660d0ac45
parent 212 6befdc90c967
child 275 36ff0ccd4253
--- a/src/pyams_portal/template.py	Thu Jan 03 17:50:58 2019 +0100
+++ b/src/pyams_portal/template.py	Thu Jan 17 10:45:18 2019 +0100
@@ -27,17 +27,18 @@
 from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
 from zope.traversing.interfaces import ITraversable
 
-from pyams_portal import _
 from pyams_portal.interfaces import IPortalPortletsConfiguration, IPortalTemplate, IPortalTemplateConfiguration, \
     IPortalTemplateContainer, IPortalTemplateContainerConfiguration, IPortlet, IPortletConfiguration, \
     PORTLETS_CONFIGURATION_KEY, TEMPLATE_CONFIGURATION_KEY, TEMPLATE_CONTAINER_CONFIGURATION_KEY
-from pyams_portal.portlet import PortalPortletsConfiguration
 from pyams_portal.slot import SlotConfiguration
 from pyams_utils.adapter import ContextAdapter, adapter_config, get_annotation_adapter
+from pyams_utils.factory import factory_config
 from pyams_utils.registry import get_local_registry, get_utility
 from pyams_utils.request import check_request
 from pyams_utils.vocabulary import vocabulary_config
 
+from pyams_portal import _
+
 
 #
 # Portal templates container
@@ -54,7 +55,7 @@
         return self.last_portlet_id
 
 
-@implementer(IPortalTemplateContainerConfiguration)
+@factory_config(IPortalTemplateContainerConfiguration)
 class PortalTemplateContainerConfiguration(Persistent, Contained):
     """Portal template container configuration"""
 
@@ -64,7 +65,7 @@
 @adapter_config(context=IPortalTemplateContainer, provides=IPortalTemplateContainerConfiguration)
 def portal_template_container_configuration_adapter(context):
     """Portal template container configuration factory"""
-    return get_annotation_adapter(context, TEMPLATE_CONTAINER_CONFIGURATION_KEY, PortalTemplateContainerConfiguration)
+    return get_annotation_adapter(context, TEMPLATE_CONTAINER_CONFIGURATION_KEY, IPortalTemplateContainerConfiguration)
 
 
 #
@@ -108,7 +109,7 @@
 # Portal template configuration
 #
 
-@implementer(IPortalTemplateConfiguration)
+@factory_config(IPortalTemplateConfiguration)
 class PortalTemplateConfiguration(Persistent, Contained):
     """Portal template configuration"""
 
@@ -298,6 +299,12 @@
             IPortalPortletsConfiguration(self.__parent__).delete_portlet_configuration(portlet_id)
 
 
+@adapter_config(context=IPortalTemplate, provides=IPortalTemplateConfiguration)
+def portal_template_configuration_factory(context):
+    """Portal template configuration adapter"""
+    return get_annotation_adapter(context, TEMPLATE_CONFIGURATION_KEY, IPortalTemplateConfiguration)
+
+
 @vocabulary_config(name='PyAMS template slots')
 class PortalTemplateSlotsVocabulary(SimpleVocabulary):
     """Portal template slots vocabulary"""
@@ -308,12 +315,6 @@
         super(PortalTemplateSlotsVocabulary, self).__init__(terms)
 
 
-@adapter_config(context=IPortalTemplate, provides=IPortalTemplateConfiguration)
-def portal_template_configuration_factory(context):
-    """Portal template configuration adapter"""
-    return get_annotation_adapter(context, TEMPLATE_CONFIGURATION_KEY, PortalTemplateConfiguration)
-
-
 @adapter_config(name='portlet', context=IPortalTemplate, provides=ITraversable)
 class PortalTemplatePortletTraverser(ContextAdapter):
     """++portlet++ template traverser"""
@@ -333,4 +334,4 @@
 @adapter_config(context=IPortalTemplate, provides=IPortalPortletsConfiguration)
 def portal_template_portlets_configuration_adapter(template):
     """Portal template portlets configuration adapter"""
-    return get_annotation_adapter(template, PORTLETS_CONFIGURATION_KEY, PortalPortletsConfiguration)
+    return get_annotation_adapter(template, PORTLETS_CONFIGURATION_KEY, IPortalPortletsConfiguration)