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

Casey Duncan casey at zope.com
Sat Feb 21 23:20:24 EST 2004


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

Modified Files:
	identity.py 
Log Message:
multi-set ops for identity sets now work properly when passed an iterator of sets


=== Packages/pypes/pypes/identity.py 1.8 => 1.9 ===
--- Packages/pypes/pypes/identity.py:1.8	Wed Feb 18 00:08:09 2004
+++ Packages/pypes/pypes/identity.py	Sat Feb 21 23:19:53 2004
@@ -267,16 +267,17 @@
         
 ## Multi-set operations ##
 
-
 def multiUnion(identity_sets):
     """Return an identity set which is the union of the sequence of identity
     sets specified
     """
-    if identity_sets:
-        dbconn = getattr(identity_sets[0], '_p_jar', None)
-    else:
-        return IdentitySet()
-    idunion = IIBTree.multiunion([set._idset for set in identity_sets])
+    idsets = []
+    dbconn = None
+    for set in identity_sets:
+        idsets.append(set._idset)
+        if dbconn is None:
+            dbconn = getattr(set, '_p_jar', None)
+    idunion = IIBTree.multiunion(idsets)
     return IdentitySet.fromIdSet(idunion, dbconn)
 
 
@@ -284,12 +285,11 @@
     """Return an identity set which is the intersection of the sequence of 
     identity sets specified
     """
-    if identity_sets:
-        dbconn = getattr(identity_sets[0], '_p_jar', None)
-    else:
-        return IdentitySet()
+    dbconn = None
     idsect = None
     for set in identity_sets:
+        if dbconn is None:
+            dbconn = getattr(set, '_p_jar', None)
         if not set:
             # Short circuit on empty set
             return IdentitySet()




More information about the Zope-CVS mailing list