Get ZEO connection settings as JSON object ZTK-1.1
authorThierry Florac <tflorac@ulthar.net>
Fri, 21 Sep 2012 01:18:08 +0200
branchZTK-1.1
changeset 171 0e8925323082
parent 170 a08e9a1c5b07
child 172 cca95b4ff0c5
child 173 7164eb24f949
Get ZEO connection settings as JSON object
src/ztfy/utils/interfaces.py
src/ztfy/utils/zodb.py
--- a/src/ztfy/utils/interfaces.py	Thu Sep 20 19:13:01 2012 +0200
+++ b/src/ztfy/utils/interfaces.py	Fri Sep 21 01:18:08 2012 +0200
@@ -179,5 +179,8 @@
                             description=_("Realm name on ZEO server"),
                             required=False)
 
+    def getJSONSettings(self):
+        """Get ZEO connection setting as a JSON dict"""
+
     def getConnection(self, wait=False):
         """Open ZEO connection with given settings"""
--- a/src/ztfy/utils/zodb.py	Thu Sep 20 19:13:01 2012 +0200
+++ b/src/ztfy/utils/zodb.py	Fri Sep 21 01:18:08 2012 +0200
@@ -34,6 +34,7 @@
 from zope.componentvocabulary.vocabulary import UtilityVocabulary
 from zope.container.contained import Contained
 from zope.interface import implementer, implements, classProvides
+from zope.schema import getFieldNames
 from zope.schema.fieldproperty import FieldProperty
 
 # import local packages
@@ -51,6 +52,12 @@
     password = FieldProperty(IZEOConnection['password'])
     server_realm = FieldProperty(IZEOConnection['server_realm'])
 
+    def getJSONSettings(self):
+        result = []
+        for name in getFieldNames(IZEOConnection):
+            result[name] = getattr(self, name)
+        return result
+
     def getConnection(self, wait=False, get_storage=False):
         """Get a tuple made of storage and DB connection for given settings"""
         storage = ClientStorage.ClientStorage((str(self.server_name), self.server_port),