Changed vocabulary declaration
authorThierry Florac <thierry.florac@onf.fr>
Tue, 15 Nov 2016 09:43:36 +0100
changeset 23 06e3617fe77d
parent 22 9491c1528b80
child 24 c70908550e8f
Changed vocabulary declaration
src/pyams_alchemy/engine.py
--- a/src/pyams_alchemy/engine.py	Mon Oct 24 16:59:33 2016 +0200
+++ b/src/pyams_alchemy/engine.py	Tue Nov 15 09:43:36 2016 +0100
@@ -30,19 +30,18 @@
 from pyams_alchemy.interfaces import REQUEST_SESSION_KEY, IAlchemyEngineUtility
 from pyams_utils.interfaces.site import IOptionalUtility
 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent
-from zope.schema.interfaces import IVocabularyFactory
 
 # import packages
 from persistent import Persistent
 from persistent.dict import PersistentDict
 from pyams_utils.registry import query_utility
 from pyams_utils.request import check_request, get_request_data, set_request_data
+from pyams_utils.vocabulary import vocabulary_config
 from pyramid.events import subscriber
 from zope.componentvocabulary.vocabulary import UtilityVocabulary
 from zope.container.contained import Contained
-from zope.interface import implementer, provider
+from zope.interface import implementer
 from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import getVocabularyRegistry
 from zope.sqlalchemy.datamanager import _SESSION_STATE, STATUS_READONLY, STATUS_ACTIVE, \
     ZopeTransactionExtension, join_transaction
 
@@ -245,11 +244,9 @@
     return session
 
 
-@provider(IVocabularyFactory)
+@vocabulary_config(name='PyAMS SQLAlchemy engines')
 class EnginesVocabulary(UtilityVocabulary):
     """SQLAlchemy engines vocabulary"""
 
     interface = IAlchemyEngineUtility
     nameOnly = True
-
-getVocabularyRegistry().register('PyAMS SQLAlchemy engines', EnginesVocabulary)