Adjust for the fact that Python 2.5 doesn't have collections.MutableSet.
authorEvan Broder <broder@mit.edu>
Mon, 23 Nov 2009 04:06:44 +0000 (23:06 -0500)
committerEvan Broder <broder@mit.edu>
Mon, 23 Nov 2009 04:11:53 +0000 (23:11 -0500)
When the MutableSet mixin isn't available, we fall back on just
deriving from object. This means that comparisons between membership
sets like __le__ as well as operators like __or__ aren't available,
but it seems unlikely those will be used for manipulating the AFS
protection database.

Signed-off-by: Evan Broder <broder@mit.edu>

afs/pts.py

index 4d3e17c..f99bc8f 100644 (file)
@@ -1,7 +1,12 @@
 import collections
 from afs import _pts
 
 import collections
 from afs import _pts
 
-class PTRelationSet(collections.MutableSet):
+try:
+    SetMixin = collections.MutableSet
+except AttributeError:
+    SetMixin = object
+
+class PTRelationSet(SetMixin):
     """Collection class for the groups/members of a PTEntry.
 
     This class, which acts like a set, is actually a view of the
     """Collection class for the groups/members of a PTEntry.
 
     This class, which acts like a set, is actually a view of the
@@ -167,6 +172,16 @@ class PTRelationSet(collections.MutableSet):
 
         self._discard(elt)
 
 
         self._discard(elt)
 
+    def remove(self, elt):
+        """Remove an entity from a group; it must already be a member.
+
+        If the entity is not a member, raise a KeyError.
+        """
+        if elt not in self:
+            raise KeyError(elt)
+
+        self.discard(elt)
+
 
 class PTEntry(object):
     """An entry in the AFS protection database.
 
 class PTEntry(object):
     """An entry in the AFS protection database.