[Zodb-checkins] CVS: Zope/lib/python/BTrees - Length.py:1.6.118.2

Jim Fulton cvs-admin at zope.org
Thu Nov 27 10:34:24 EST 2003


Update of /cvs-repository/Zope/lib/python/BTrees
In directory cvs.zope.org:/tmp/cvs-serv7869/lib/python/BTrees

Modified Files:
      Tag: Zope-2_8-devel-branch
	Length.py 
Log Message:
Got tests to pass except test that was previously (and still) failing
on head.


=== Zope/lib/python/BTrees/Length.py 1.6.118.1 => 1.6.118.2 ===
--- Zope/lib/python/BTrees/Length.py:1.6.118.1	Tue Nov 25 15:17:26 2003
+++ Zope/lib/python/BTrees/Length.py	Thu Nov 27 10:33:52 2003
@@ -20,24 +20,39 @@
     Objects that use BTrees need to keep track of lengths themselves.
     This class provides an object for doing this.
 
-    As a bonus, the object support application-level conflict resolution.
+    As a bonus, the object support application-level conflict
+    resolution.
+
+    It is tempting to to assign length objects to __len__ attributes
+    to provide instance-specific __len__ methods. However, this no
+    longer works as expected, because new-style classes cache
+    class-defined slot methods (like __len__) in C type slots.  Thus,
+    instance-define slot fillers are ignores.
+    
     """
 
-    def __init__(self, v=0): self.value=v
+    def __init__(self, v=0):
+        self.value = v
 
-    def __getstate__(self): return self.value
+    def __getstate__(self):
+        return self.value
 
-    def __setstate__(self, v): self.value=v
+    def __setstate__(self, v):
+        self.value = v
 
-    def set(self, v): self.value=v
+    def set(self, v):
+        self.value = v
 
-    def _p_resolveConflict(self, old, s1, s2): return s1 + s2 - old
+    def _p_resolveConflict(self, old, s1, s2):
+        return s1 + s2 - old
 
     def _p_independent(self):
         # My state doesn't depend on or materially effect the state of
         # other objects.
         return 1
 
-    def change(self, delta): self.value = self.value + delta
+    def change(self, delta):
+        self.value += delta
 
-    def __call__(self, *args): return self.value
+    def __call__(self, *args):
+        return self.value




More information about the Zodb-checkins mailing list