[Zope-CVS] CVS: Packages/pypes/pypes - identity.py:1.10

Casey Duncan casey at zope.com
Sun Feb 22 00:39:05 EST 2004


Update of /cvs-repository/Packages/pypes/pypes
In directory cvs.zope.org:/tmp/cvs-serv6155

Modified Files:
	identity.py 
Log Message:
Make issubset and issuperset work between IdentitySets and other set-like things (ie Extents)
Make sure set operations pass their zodb connection on to their derived sets so that they can access pypes services


=== Packages/pypes/pypes/identity.py 1.9 => 1.10 ===
--- Packages/pypes/pypes/identity.py:1.9	Sat Feb 21 23:19:53 2004
+++ Packages/pypes/pypes/identity.py	Sun Feb 22 00:39:04 2004
@@ -237,26 +237,38 @@
                 yield None
     
     def union(self, other):
-        return self.__class__.fromIdSet(union(self._idset, other._idset))
+        return self.__class__.fromIdSet(
+            union(self._idset, other._idset), dbconn=self._p_jar)
     
     __or__ = union
     
     def difference(self, other):
-        return self.__class__.fromIdSet(difference(self._idset, other._idset))
+        return self.__class__.fromIdSet(
+            difference(self._idset, other._idset), dbconn=self._p_jar)
         
     __sub__ = difference
     
     def intersection(self, other):
         return self.__class__.fromIdSet(
-            intersection(self._idset, other._idset))  
+            intersection(self._idset, other._idset), dbconn=self._p_jar)  
     
     __and__ = intersection
     
     def issubset(self, other):
-        return not difference(self._idset, other._idset)
+        if isinstance(other, IdentitySet):
+            return not difference(self._idset, other._idset)
+        elif hasattr(other, 'issuperset'): # XXX Interface check instead?
+            return other.issuperset(self)
+        else:
+            raise TypeError, 'wrong type for issubset'
     
     def issuperset(self, other):
-        return not difference(other._idset, self._idset)
+        if isinstance(other, IdentitySet):
+            return not difference(other._idset, self._idset)
+        elif hasattr(other, 'issubset'): # XXX Interface check instead?
+            return other.issubset(self)
+        else:
+            raise TypeError, 'wrong type for issuperset'
         
     def __eq__(self, other):
         return self.issubset(other) and self.issuperset(other)
@@ -278,7 +290,7 @@
         if dbconn is None:
             dbconn = getattr(set, '_p_jar', None)
     idunion = IIBTree.multiunion(idsets)
-    return IdentitySet.fromIdSet(idunion, dbconn)
+    return IdentitySet.fromIdSet(idunion, dbconn=dbconn)
 
 
 def multiIntersection(identity_sets):
@@ -297,7 +309,7 @@
         if not idsect:
             # Short circuit on empty intersect
             return IdentitySet()
-    return IdentitySet.fromIdSet(idsect, dbconn)
+    return IdentitySet.fromIdSet(idsect, dbconn=dbconn)
                 
 
 ## Id Event Messsage Types ##




More information about the Zope-CVS mailing list