--- a/src/ztfy/utils/interfaces.py Fri Sep 21 01:18:08 2012 +0200
+++ b/src/ztfy/utils/interfaces.py Fri Sep 21 12:36:10 2012 +0200
@@ -179,8 +179,11 @@
description=_("Realm name on ZEO server"),
required=False)
- def getJSONSettings(self):
+ def getSettings(self):
"""Get ZEO connection setting as a JSON dict"""
+ def update(self, settings):
+ """Update internal fields with given settings dict"""
+
def getConnection(self, wait=False):
"""Open ZEO connection with given settings"""
--- a/src/ztfy/utils/zodb.py Fri Sep 21 01:18:08 2012 +0200
+++ b/src/ztfy/utils/zodb.py Fri Sep 21 12:36:10 2012 +0200
@@ -52,18 +52,24 @@
password = FieldProperty(IZEOConnection['password'])
server_realm = FieldProperty(IZEOConnection['server_realm'])
- def getJSONSettings(self):
+ def getSettings(self):
+ """Get settings dict"""
result = []
for name in getFieldNames(IZEOConnection):
result[name] = getattr(self, name)
return result
+ def update(self, settings):
+ assert isinstance(settings, dict)
+ for key, value in settings.items():
+ setattr(self, key, value if isinstance(value, int) else unicode(value))
+
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),
- storage=self.server_storage,
- username=self.server_username or '',
- password=self.server_password or '',
+ storage=self.storage,
+ username=self.username or '',
+ password=self.password or '',
realm=self.server_realm,
wait=wait)
db = DB(storage)