Add ZEO connections vocabulary ZTK-1.1
authorThierry Florac <tflorac@ulthar.net>
Thu, 20 Sep 2012 19:13:01 +0200
branchZTK-1.1
changeset 170 a08e9a1c5b07
parent 169 b4b587dd45ca
child 171 0e8925323082
Add ZEO connections vocabulary
src/ztfy/utils/zodb.py
src/ztfy/utils/zodb.zcml
--- a/src/ztfy/utils/zodb.py	Thu Sep 20 17:06:22 2012 +0200
+++ b/src/ztfy/utils/zodb.py	Thu Sep 20 19:13:01 2012 +0200
@@ -17,11 +17,12 @@
 
 # import standard packages
 from persistent import Persistent
+from persistent.interfaces import IPersistent
+from transaction.interfaces import ITransactionManager
 
 # import Zope3 interfaces
-from persistent.interfaces import IPersistent
-from transaction.interfaces import ITransactionManager
 from ZODB.interfaces import IConnection
+from zope.schema.interfaces import IVocabularyFactory
 
 # import local interfaces
 from ztfy.utils.interfaces import IZEOConnection
@@ -30,8 +31,9 @@
 from ZEO import ClientStorage
 from ZODB import DB
 from zope.component import adapter
+from zope.componentvocabulary.vocabulary import UtilityVocabulary
 from zope.container.contained import Contained
-from zope.interface import implementer, implements
+from zope.interface import implementer, implements, classProvides
 from zope.schema.fieldproperty import FieldProperty
 
 # import local packages
@@ -65,6 +67,14 @@
     """Persistent ZEO connection settings utility"""
 
 
+class ZEOConnectionVocabulary(UtilityVocabulary):
+    """ZEO connections vocabulary"""
+
+    classProvides(IVocabularyFactory)
+
+    interface = IZEOConnection
+    nameOnly = True
+
 
 # IPersistent adapters copied from zc.twist package
 # also register this for adapting from IConnection
--- a/src/ztfy/utils/zodb.zcml	Thu Sep 20 17:06:22 2012 +0200
+++ b/src/ztfy/utils/zodb.zcml	Thu Sep 20 19:13:01 2012 +0200
@@ -18,4 +18,8 @@
 			permission="zope.ManageServices" />
 	</class>
 
+	<utility
+		name="ZEO connections"
+		component=".zodb.ZEOConnectionVocabulary" />
+
 </configure>
\ No newline at end of file