Changed vocabularies declarations
authorThierry Florac <thierry.florac@onf.fr>
Tue, 15 Nov 2016 10:24:40 +0100
changeset 20 c3f7c8290792
parent 19 f4462709ee4d
child 21 064bf303cc33
Changed vocabularies declarations
src/pyams_portal/portlet.py
src/pyams_portal/template.py
--- a/src/pyams_portal/portlet.py	Tue Nov 15 10:24:09 2016 +0100
+++ b/src/pyams_portal/portlet.py	Tue Nov 15 10:24:40 2016 +0100
@@ -22,7 +22,6 @@
 # import interfaces
 from pyams_portal.interfaces import IPortlet, IPortletSettings, IPortletConfiguration, IPortletPreviewer, \
     IPortletRenderer, IPortalPortletsConfiguration, IPortalTemplate, IPortalContext, IPortalPage
-from zope.schema.interfaces import IVocabularyFactory
 from zope.traversing.interfaces import ITraversable
 
 # import packages
@@ -30,16 +29,17 @@
 from persistent.mapping import PersistentMapping
 from pyams_utils.adapter import adapter_config, ContextAdapter
 from pyams_utils.request import check_request
+from pyams_utils.vocabulary import vocabulary_config
 from pyams_viewlet.viewlet import ContentProvider
 from pyramid.exceptions import ConfigurationError
 from pyramid.threadlocal import get_current_registry
 from zope.container.contained import Contained
 from zope.copy import clone
-from zope.interface import implementer, provider
+from zope.interface import implementer
 from zope.lifecycleevent import ObjectCreatedEvent
 from zope.location import locate
 from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm, getVocabularyRegistry
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 
 #
@@ -105,7 +105,7 @@
         return wrapped
 
 
-@provider(IVocabularyFactory)
+@vocabulary_config(name='PyAMS portal portlets')
 class PortletVocabulary(SimpleVocabulary):
     """Portlet vocabulary"""
 
@@ -117,8 +117,6 @@
                  for name, util in sorted(utils, key=lambda x: translate(x[1].label))]
         super(PortletVocabulary, self).__init__(terms)
 
-getVocabularyRegistry().register('PyAMS portal portlets', PortletVocabulary)
-
 
 #
 # Portlets renderers
--- a/src/pyams_portal/template.py	Tue Nov 15 10:24:09 2016 +0100
+++ b/src/pyams_portal/template.py	Tue Nov 15 10:24:40 2016 +0100
@@ -32,6 +32,7 @@
 from pyams_utils.adapter import adapter_config, ContextAdapter
 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 pyramid.events import subscriber
 from pyramid.threadlocal import get_current_registry
 from zope.componentvocabulary.vocabulary import UtilityVocabulary
@@ -42,7 +43,7 @@
 from zope.lifecycleevent import ObjectCreatedEvent
 from zope.location import locate
 from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm, getVocabularyRegistry
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 
 #
@@ -106,14 +107,13 @@
         registry.unregisterUtility(event.object, IPortalTemplate, name=event.object.name)
 
 
+@vocabulary_config(name='PyAMS portal templates')
 class PortalTemplatesVocabulary(UtilityVocabulary):
     """Portal templates vocabulary"""
 
     interface = IPortalTemplate
     nameOnly = True
 
-getVocabularyRegistry().register('PyAMS portal templates', PortalTemplatesVocabulary)
-
 
 #
 # Portal template configuration
@@ -322,6 +322,7 @@
             IPortalPortletsConfiguration(self.__parent__).delete_portlet_configuration(portlet_id)
 
 
+@vocabulary_config(name='PyAMS template slots')
 class PortalTemplateSlotsVocabulary(SimpleVocabulary):
     """Portal template slots vocabulary"""
 
@@ -330,8 +331,6 @@
         terms = [SimpleTerm(slot_name) for slot_name in sorted(config.slot_names)]
         super(PortalTemplateSlotsVocabulary, self).__init__(terms)
 
-getVocabularyRegistry().register('PyAMS template slots', PortalTemplateSlotsVocabulary)
-
 
 @adapter_config(context=IPortalTemplate, provides=IPortalTemplateConfiguration)
 def PortalTemplateConfigurationFactory(context):