src/pyams_portal/template.py
changeset 20 c3f7c8290792
parent 5 670b7956c689
child 39 f0ef959855e7
--- 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):