Changed ZEO connections vocabulary to use local registry
authorThierry Florac <thierry.florac@onf.fr>
Thu, 23 Jul 2015 17:26:22 +0200
changeset 41 639c16986e44
parent 40 b0544bab0a9f
child 42 19c2ddd411a1
Changed ZEO connections vocabulary to use local registry
src/pyams_utils/zodb.py
--- a/src/pyams_utils/zodb.py	Wed Jul 22 17:26:41 2015 +0200
+++ b/src/pyams_utils/zodb.py	Thu Jul 23 17:26:22 2015 +0200
@@ -9,6 +9,7 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyams_utils.registry import get_utilities_for
 
 __docformat__ = 'restructuredtext'
 
@@ -37,7 +38,7 @@
 from zope.interface import implementer, provider
 from zope.schema import getFieldNames
 from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import getVocabularyRegistry
+from zope.schema.vocabulary import getVocabularyRegistry, SimpleVocabulary, SimpleTerm
 
 
 @adapter_config(context=IPersistent, provides=IConnection)
@@ -150,12 +151,16 @@
 
 
 @provider(IVocabularyFactory)
-class ZEOConnectionVocabulary(UtilityVocabulary):
+class ZEOConnectionVocabulary(SimpleVocabulary):
     """ZEO connections vocabulary"""
 
     interface = IZEOConnection
     nameOnly = True
 
+    def __init__(self, context=None):
+        terms = [SimpleTerm(name, title=util.name) for name, util in get_utilities_for(IZEOConnection)]
+        super(ZEOConnectionVocabulary, self).__init__(terms)
+
 getVocabularyRegistry().register('PyAMS ZEO connections', ZEOConnectionVocabulary)