Added ISet interface ZTK-1.1
authorThierry Florac <thierry.florac@onf.fr>
Wed, 16 Oct 2013 14:32:24 +0200
branchZTK-1.1
changeset 233 6c087119379d
parent 232 dabc8ebe131d
child 234 69503d5058a1
Added ISet interface
src/ztfy/utils/configure.zcml
src/ztfy/utils/interfaces.py
--- a/src/ztfy/utils/configure.zcml	Wed Oct 16 14:31:37 2013 +0200
+++ b/src/ztfy/utils/configure.zcml	Wed Oct 16 14:32:24 2013 +0200
@@ -1,6 +1,7 @@
 <configure
 	xmlns="http://namespaces.zope.org/zope"
 	xmlns:i18n="http://namespaces.zope.org/i18n"
+	xmlns:zcml="http://namespaces.zope.org/zcml"
 	i18n_domain="ztfy.utils">
 
 	<i18n:registerTranslations directory="locales" />
@@ -18,6 +19,18 @@
 		factory=".schema.DottedDecimalDataConverter"
 		trusted="True" />
 
+	<!-- zc.set classes -->
+	<class
+		zcml:condition="installed zc.set"
+		class="zc.set.Set">
+		<require
+			interface=".interfaces.ISetInfo"
+			permission="zope.View" />
+		<require
+			interface=".interfaces.ISetWriter"
+			permission="zope.ManageContent" />
+	</class>
+
 	<!-- Sub-packages -->
 	<include package=".tal" />
 
--- a/src/ztfy/utils/interfaces.py	Wed Oct 16 14:31:37 2013 +0200
+++ b/src/ztfy/utils/interfaces.py	Wed Oct 16 14:32:24 2013 +0200
@@ -146,6 +146,154 @@
 
 
 #
+# Generic set interfaces
+#
+
+class ISetInfo(Interface):
+    """Set-like interfaces"""
+
+    def copy(self, *args, **kwargs):
+        """ Return a shallow copy of a set. """
+
+    def difference(self, *args, **kwargs):
+        """Return the difference of two or more sets as a new set"""
+
+    def intersection(self, *args, **kwargs):
+        """Return the intersection of two or more sets as a new set"""
+
+    def isdisjoint(self, *args, **kwargs):
+        """ Return True if two sets have a null intersection. """
+
+    def issubset(self, *args, **kwargs):
+        """ Report whether another set contains this set. """
+
+    def issuperset(self, *args, **kwargs):
+        """ Report whether this set contains another set. """
+
+    def symmetric_difference(self, *args, **kwargs):
+        """Return the symmetric difference of two sets as a new set"""
+
+    def union(self, *args, **kwargs):
+        """Return the union of sets as a new set"""
+
+    def __and__(self, y):
+        """ x.__and__(y) <==> x&y """
+
+    def __cmp__(self, y):
+        """ x.__cmp__(y) <==> cmp(x,y) """
+
+    def __contains__(self, y):
+        """ x.__contains__(y) <==> y in x. """
+
+    def __eq__(self, y):
+        """ x.__eq__(y) <==> x==y """
+
+    def __getattribute__(self, name):
+        """ x.__getattribute__('name') <==> x.name """
+
+    def __ge__(self, y):
+        """ x.__ge__(y) <==> x>=y """
+
+    def __gt__(self, y):
+        """ x.__gt__(y) <==> x>y """
+
+    def __hash__(self):
+        """Compute hash value"""
+
+    def __iter__(self):
+        """ x.__iter__() <==> iter(x) """
+
+    def __len__(self):
+        """ x.__len__() <==> len(x) """
+
+    def __le__(self, y): # real signature unknown; restored from __doc__
+        """ x.__le__(y) <==> x<=y """
+
+    def __lt__(self, y): # real signature unknown; restored from __doc__
+        """ x.__lt__(y) <==> x<y """
+
+    def __ne__(self, y): # real signature unknown; restored from __doc__
+        """ x.__ne__(y) <==> x!=y """
+
+    def __or__(self, y): # real signature unknown; restored from __doc__
+        """ x.__or__(y) <==> x|y """
+
+    def __reduce__(self, *args, **kwargs): # real signature unknown
+        """ Return state information for pickling. """
+
+    def __repr__(self): # real signature unknown; restored from __doc__
+        """ x.__repr__() <==> repr(x) """
+
+    def __rand__(self, y):
+        """ x.__rand__(y) <==> y&x """
+
+    def __ror__(self, y):
+        """ x.__ror__(y) <==> y|x """
+
+    def __rsub__(self, y):
+        """ x.__rsub__(y) <==> y-x """
+
+    def __rxor__(self, y):
+        """ x.__rxor__(y) <==> y^x """
+
+    def __sizeof__(self):
+        """ S.__sizeof__() -> size of S in memory, in bytes """
+
+    def __sub__(self, y):
+        """ x.__sub__(y) <==> x-y """
+
+    def __xor__(self, y):
+        """ x.__xor__(y) <==> x^y """
+
+
+class ISetWriter(Interface):
+    """Set-like writer interface"""
+
+    def add(self, *args, **kwargs):
+        """Add an element to set"""
+
+    def clear(self, *args, **kwargs):
+        """ Remove all elements from this set. """
+
+    def difference_update(self, *args, **kwargs):
+        """ Remove all elements of another set from this set. """
+
+    def discard(self, *args, **kwargs):
+        """Remove an element from a set if it is a member"""
+
+    def intersection_update(self, *args, **kwargs):
+        """ Update a set with the intersection of itself and another. """
+
+    def pop(self, *args, **kwargs):
+        """Remove and return an arbitrary set element"""
+
+    def remove(self, *args, **kwargs):
+        """Remove an element from a set; it must be a member"""
+
+    def symmetric_difference_update(self, *args, **kwargs):
+        """ Update a set with the symmetric difference of itself and another """
+
+    def update(self, *args, **kwargs):
+        """ Update a set with the union of itself and others. """
+
+    def __iand__(self, y):
+        """ x.__iand__(y) <==> x&=y """
+
+    def __ior__(self, y):
+        """ x.__ior__(y) <==> x|=y """
+
+    def __isub__(self, y):
+        """ x.__isub__(y) <==> x-=y """
+
+    def __ixor__(self, y):
+        """ x.__ixor__(y) <==> x^=y """
+
+
+class ISet(ISetInfo, ISetWriter):
+    """Marker interface for set-like components"""
+
+
+#
 # ZEO connection settings interface
 #