# HG changeset patch # User Thierry Florac # Date 1437665182 -7200 # Node ID 639c16986e4459f118fc4a3ff1b5a6f8605dde17 # Parent b0544bab0a9f06d87b11752633744dc173252f17 Changed ZEO connections vocabulary to use local registry diff -r b0544bab0a9f -r 639c16986e44 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)