[Zope-CVS] CVS: Packages/pypes/pypes - identity.py:1.18 interfaces.py:1.17

Casey Duncan casey at zope.com
Mon Apr 12 22:25:04 EDT 2004


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

Modified Files:
	identity.py interfaces.py 
Log Message:
Genericize set interfaces to reduce redundancy


=== Packages/pypes/pypes/identity.py 1.17 => 1.18 ===
--- Packages/pypes/pypes/identity.py:1.17	Mon Apr 12 00:45:42 2004
+++ Packages/pypes/pypes/identity.py	Mon Apr 12 22:24:32 2004
@@ -28,7 +28,7 @@
 from BTrees.Length import Length
 from pypes import services
 from pypes.event import PypesMessage
-from pypes.interfaces import IIdentityService, IIdentitySet, IIdentityMessage
+from pypes.interfaces import IIdentityService, IMutableSet, IIdentityMessage
 from pypes.exceptions import PypesError, PypesLookupError
 from pypes.exceptions import IdentityError, IdentityKeyError, SetLookupError
 
@@ -133,9 +133,13 @@
 
 
 class IdentitySet(Persistent):
-    """Efficient persistent sets of id-registered objects"""
+    """A set of unique identified objects. Since the set relies
+    on persistent identity, its members may be mutable. Identity sets 
+    weakly reference their members, so being a member of a set does not
+    guarantee continued persistence.
+    """
     
-    implements(IIdentitySet)
+    implements(IMutableSet)
     
     def __init__(self, objs=None):
         """Identity sets can be constructed empty, or populated by an


=== Packages/pypes/pypes/interfaces.py 1.16 => 1.17 ===
--- Packages/pypes/pypes/interfaces.py:1.16	Mon Apr 12 00:41:43 2004
+++ Packages/pypes/pypes/interfaces.py	Mon Apr 12 22:24:32 2004
@@ -109,25 +109,9 @@
 
     def idSet():
         """Return an identity set of all registered objects."""
-
-class IIdentitySet(Interface):
-    """A set of unique identified objects. Since the set relies
-    on persistent identity, its members may be mutable. Identity sets 
-    weakly reference their members, so being a member of a set does not
-    guarantee continued persistence. Implementations may use the event
-    service to keep informed of object registrations"""
-    
-    def add(obj):
-        """Add obj to the set. Return true if obj was not a member already,
-        false if so. In the latter case insert does not change the set. Raise
-        IdentityError if obj is not identified
-        """
-    
-    def remove(obj):
-        """Remove obj from set. raise SetLookupError if obj is not in the set"""
         
-    def update(objs):
-        """Iterate objs and add its members to the set in place"""
+class ISet(Interface):
+    """Basic immutable set of objects"""
     
     def __contains__(obj):
         """Return true if obj is in the set"""
@@ -166,6 +150,21 @@
         
     def __eq__(other):
         """Return true if this set and other contain the same members"""
+
+
+class IMutableSet(ISet):
+    """Mutable set of objects"""
+    
+    def add(obj):
+        """Add obj to the set. Return true if obj was not a member already,
+        false if so. In the latter case insert does not change the set.
+        """
+    
+    def remove(obj):
+        """Remove obj from set. raise SetLookupError if obj is not in the set"""
+        
+    def update(objs):
+        """Iterate objs and add its members to the set in place"""
         
     
 class IEventService(IPersistentService):
@@ -296,7 +295,7 @@
         """Update the extent map from all identified objects"""
         
         
-class IExtent(Interface):
+class IExtent(ISet):
     """Automated set of identified objects.
     
     Extents are either provided by the extent service or derived from other
@@ -308,53 +307,11 @@
     between extents and identity sets are also supported; resulting in a new
     identity set.
     """
-    
-    def __contains__(obj):
-        """Return true if obj is in the extent"""
-    
-    def __len__():
-        """Return extent member count"""
-    
-    def __iter__():
-        """Return an iterator of the members of the extent"""
-    
-    def union(other):
-        """Return a derived extent or identity set whos members are the union 
-        of self and other"""
-        
-    def __or__(other):
-        """Alias for union in an expression"""
-        
-    def difference(other):
-        """return a derived extent or identity set whos members are in self 
-        but not in other"""
-    
-    def __sub__(other):
-        """Alias for difference"""
-        
-    def intersection(other):
-        """Return a derived extent or identity set whos members are in both 
-        self and other"""
-    
-    def __and__(other):
-        """Compute the intersection between self and other and return the 
-        resulting derived extent or identity set
-        """
-    
+
     def __invert__():
         """Return an extent containing all identified objects except those
         in self.
         """
-    
-    def issubset(other):
-        """Return true if all members of self are also in other"""
-    
-    def issuperset(other):
-        """Return true if all members of other are also in self"""
-        
-    def __eq__(other):
-        """Return true if this extent and other contain the same members"""
-
 
 class ICanonicalExtent(IExtent):
     """An extent of a single interface or class provided directly by the
@@ -535,7 +492,7 @@
     more IExpression objects.
     """
     
-    def __init__(inputs=None, filter_expr=None, order=None, limit=None):
+    def __init__(inputs=None, criteria=None, order=None, limit=None):
         """Query constructor. Arguments values override defaults provided
         by the class (if any).Query classes that supply defaults for all 
         the necessary arguments can be constructed with no arguments.
@@ -544,9 +501,11 @@
         mapping of 'name':'input' pairs. Inputs may be any sequence of 
         objects, but are typically sets of identified objects.
         
-        filter_expr -- An IExpression object used as the query filter.
+        criteria -- An IExpression object used as the criteria for selecting
+        objects from the inputs.
         
-        order -- An IOrderExpression object or a sequence of them.
+        order -- An IOrderExpression object or a sequence of them that
+        determines the order of the results output.
         
         limit -- An integer value specifying the maximum number of results
         the query returns.
@@ -557,11 +516,11 @@
     
     def inputMap():
         """Return a dict containing the input names and input objects for its
-        respective keys and values
+        respective keys and values.
         """
     
-    def filterExpr():
-        """Return the IExpression object used as the query filter"""
+    def criteriaExpr():
+        """Return the IExpression object used as the query criteria"""
         
     def orderExprs():
         """Return a sequence of IOrderExpression objects that determine the




More information about the Zope-CVS mailing list