[Zope-Checkins] CVS: Zope/lib/python/SearchIndex - UnIndex.py:1.33.26.1

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


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

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


=== Zope/lib/python/SearchIndex/UnIndex.py 1.33 => 1.33.26.1 ===
--- Zope/lib/python/SearchIndex/UnIndex.py:1.33	Fri May  9 16:11:55 2003
+++ Zope/lib/python/SearchIndex/UnIndex.py	Thu Nov 27 10:33:58 2003
@@ -75,9 +75,22 @@
         self.ignore_ex=ignore_ex        # currently unimplimented
         self.call_methods=call_methods
 
-        self.__len__=BTrees.Length.Length() # see __len__ method docstring
+        # Note that it was unfortunate to use __len__ as the attribute
+        # name here. New-style classes cache slot methods in C slot
+        # pointers. The result is that instances can't override slots.
+        # This is not easy to change on account of old objects with
+        # __len__ attr.
+
+        self.__len__=BTrees.Length.Length()
         self.clear()
 
+    def __len__(self):
+        try:
+            return self.__dict__['__len__']()
+        except KeyError:
+            # Fallback for really old indexes
+            return len(self._unindex)
+
     def clear(self):
         # inplace opportunistic conversion from old-style to new style BTrees
         try: self.__len__.set(0)
@@ -116,15 +129,6 @@
 
     def __nonzero__(self):
         return not not self._unindex
-
-    def __len__(self):
-        """Return the number of objects indexed.
-
-        This method is only called for indexes which have "old" BTrees,
-        and the *only* reason that UnIndexes maintain a __len__ is for
-        the searching code in the catalog during sorting.
-        """
-        return len(self._unindex)
 
     def histogram(self):
         """Return a mapping which provides a histogram of the number of




More information about the Zope-Checkins mailing list