Merge with cca95b4ff0c5da10a3aebf355ac26e6541ded5b4 ZTK-1.1
authorThierry Florac <tflorac@ulthar.net>
Mon, 24 Sep 2012 08:54:09 +0200
branchZTK-1.1
changeset 174 380f23a1587e
parent 173 7164eb24f949 (diff)
parent 172 cca95b4ff0c5 (current diff)
child 175 590c2e6d725e
Merge with cca95b4ff0c5da10a3aebf355ac26e6541ded5b4
src/ztfy/utils/interfaces.py
src/ztfy/utils/zodb.py
--- a/src/ztfy/utils/interfaces.py	Fri Sep 21 12:36:10 2012 +0200
+++ b/src/ztfy/utils/interfaces.py	Mon Sep 24 08:54:09 2012 +0200
@@ -42,44 +42,44 @@
 class IListInfo(Interface):
     """Custom interface used to handle list-like components"""
 
-    def count():
+    def count(self):
         """Get list items count"""
 
-    def index():
+    def index(self):
         """Get position of the given item"""
 
-    def __contains__():
-        """Check if given value is int list"""
+    def __contains__(self, value):
+        """Check if given value is in list"""
 
-    def __getitem__():
+    def __getitem__(self, index):
         """Return item at given position"""
 
-    def __iter__():
+    def __iter__(self):
         """Iterator over list items"""
 
 
 class IListWriter(Interface):
     """Writer interface for list-like components"""
 
-    def append():
+    def append(self, value):
         """Append value to list"""
 
-    def extend():
+    def extend(self, values):
         """Extend list with given items"""
 
-    def insert():
+    def insert(self, index, value):
         """Insert item to given index"""
 
-    def pop():
+    def pop(self):
         """Pop item from list and returns it"""
 
-    def remove():
+    def remove(self, value):
         """Remove given item from list"""
 
-    def reverse():
+    def reverse(self):
         """Sort list in reverse order"""
 
-    def sort():
+    def sort(self):
         """Sort list"""
 
 
@@ -94,50 +94,50 @@
 class IDictInfo(Interface):
     """Custom interface used to handle dict-like components"""
 
-    def keys():
+    def keys(self):
         """Get list of keys for the dict"""
 
-    def has_key(key):
+    def has_key(self, key):
         """Check to know if dict includes the given key"""
 
-    def get(key, default=None):
+    def get(self, key, default=None):
         """Get given key or default from dict"""
 
-    def copy():
+    def copy(self,):
         """Duplicate content of dict"""
 
-    def __contains__(key):
+    def __contains__(self, key):
         """Check if given key is in dict"""
 
-    def __getitem__(key):
+    def __getitem__(self, key):
         """Get given key value from dict"""
 
-    def __iter__():
+    def __iter__(self):
         """Iterator over dictionnary keys"""
 
 
 class IDictWriter(Interface):
     """Writer interface for dict-like components"""
 
-    def clear():
+    def clear(self):
         """Clear dict"""
 
-    def update(b):
+    def update(self, b):
         """Update dict with given values"""
 
-    def setdefault(key, failobj=None):
+    def setdefault(self, key, failobj=None):
         """Create value for given key if missing"""
 
-    def pop(key, *args):
+    def pop(self, key, *args):
         """Remove and return given key from dict"""
 
-    def popitem():
+    def popitem(self, item):
         """Pop item from dict"""
 
-    def __setitem__(key, value):
+    def __setitem__(self, key, value):
         """Update given key with given value"""
 
-    def __delitem__(key):
+    def __delitem__(self, key):
         """Remove selected key from dict"""
 
 
--- a/src/ztfy/utils/zodb.py	Fri Sep 21 12:36:10 2012 +0200
+++ b/src/ztfy/utils/zodb.py	Mon Sep 24 08:54:09 2012 +0200
@@ -53,16 +53,16 @@
     server_realm = FieldProperty(IZEOConnection['server_realm'])
 
     def getSettings(self):
-        """Get settings dict"""
-        result = []
+        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))
+        names = getFieldNames(IZEOConnection)
+        for k, v in settings.items():
+            if k in names:
+                setattr(self, k, unicode(v) if isinstance(v, str) else v)
 
     def getConnection(self, wait=False, get_storage=False):
         """Get a tuple made of storage and DB connection for given settings"""