# HG changeset patch # User Thierry Florac # Date 1348223770 -7200 # Node ID cca95b4ff0c5da10a3aebf355ac26e6541ded5b4 # Parent 0e8925323082d79a3558c99f7574e4774ba9d224 Update ZEO connection interface diff -r 0e8925323082 -r cca95b4ff0c5 src/ztfy/utils/interfaces.py --- 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""" diff -r 0e8925323082 -r cca95b4ff0c5 src/ztfy/utils/zodb.py --- 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)