Re-define IList and IDict interfaces missing after bad merge :-( ZTK-1.1
authorThierry Florac
Sat, 17 Dec 2011 18:16:05 +0100
branchZTK-1.1
changeset 99 65baa857b943
parent 98 40cbf6435cc3
child 100 6c12e94bb5c7
Re-define IList and IDict interfaces missing after bad merge :-(
ztfy/utils/interfaces.py
--- a/ztfy/utils/interfaces.py	Fri Dec 16 13:14:22 2011 +0100
+++ b/ztfy/utils/interfaces.py	Sat Dec 17 18:16:05 2011 +0100
@@ -23,9 +23,120 @@
 # import local interfaces
 
 # import Zope3 packages
+from zope.interface import Interface
 
 # import local packages
 
 
 class INewSiteManagerEvent(IObjectEvent):
     """Event interface for new site manager event"""
+
+
+#
+# Generic list interface
+#
+
+class IListInfo(Interface):
+    """Custom interface used to handle list-like components"""
+
+    def count():
+        """Get list items count"""
+
+    def index():
+        """Get position of the given item"""
+
+    def __contains__():
+        """Check if given value is int list"""
+
+    def __getitem__():
+        """Return item at given position"""
+
+    def __iter__():
+        """Iterator over list items"""
+
+
+class IListWriter(Interface):
+    """Writer interface for list-like components"""
+
+    def append():
+        """Append value to list"""
+
+    def extend():
+        """Extend list with given items"""
+
+    def insert():
+        """Insert item to given index"""
+
+    def pop():
+        """Pop item from list and returns it"""
+
+    def remove():
+        """Remove given item from list"""
+
+    def reverse():
+        """Sort list in reverse order"""
+
+    def sort():
+        """Sort list"""
+
+
+class IList(IListInfo, IListWriter):
+    """Marker interface for list-like components"""
+
+
+#
+# Generic dict interface
+#
+
+class IDictInfo(Interface):
+    """Custom interface used to handle dict-like components"""
+
+    def keys():
+        """Get list of keys for the dict"""
+
+    def has_key(key):
+        """Check to know if dict includes the given key"""
+
+    def get(key, default=None):
+        """Get given key or default from dict"""
+
+    def copy():
+        """Duplicate content of dict"""
+
+    def __contains__(key):
+        """Check if given key is in dict"""
+
+    def __getitem__(key):
+        """Get given key value from dict"""
+
+    def __iter__():
+        """Iterator over dictionnary keys"""
+
+
+class IDictWriter(Interface):
+    """Writer interface for dict-like components"""
+
+    def clear():
+        """Clear dict"""
+
+    def update(b):
+        """Update dict with given values"""
+
+    def setdefault(key, failobj=None):
+        """Create value for given key if missing"""
+
+    def pop(key, *args):
+        """Remove and return given key from dict"""
+
+    def popitem():
+        """Pop item from dict"""
+
+    def __setitem__(key, value):
+        """Update given key with given value"""
+
+    def __delitem__(key):
+        """Remove selected key from dict"""
+
+
+class IDict(IDictInfo, IDictWriter):
+    """Marker interface for dict-like components"""