[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/PathIndex - PathIndex.py:1.35.2.2

Andreas Jung cvs-admin at zope.org
Tue Nov 4 10:55:24 EST 2003


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/PathIndex
In directory cvs.zope.org:/tmp/cvs-serv5977

Modified Files:
      Tag: Zope-2_7-branch
	PathIndex.py 
Log Message:
backport of r 1.37 from HEAD


=== Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 1.35.2.1 => 1.35.2.2 ===
--- Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py:1.35.2.1	Thu Sep 18 10:16:14 2003
+++ Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py	Tue Nov  4 10:55:23 2003
@@ -113,6 +113,7 @@
         comps = filter(None, path.split('/'))
        
         if not self._unindex.has_key(docid):
+            self._.migrate_length()
             self._length.change(1)
 
         for i in range(len(comps)):
@@ -147,6 +148,7 @@
                     'Attempt to unindex document'
                     ' with id %s failed' % docid)
 
+        self._.migrate_length()
         self._length.change(-1)
         del self._unindex[docid]
 
@@ -201,12 +203,13 @@
 
     def numObjects(self):
         """ return the number of indexed objects"""
-        try:
-            return self._length()
-        except AttributeError:        # backward compatibility
-            l = len(self._unindex)
-            self._length = Length(l)
-            return l
+        self._migrate_length()
+        return self._length
+
+    def _migrate_length(self):
+        """ migrate index to use new _length attribute """
+        if not hasattr(self, '_length'):
+            self._length = Length(len(self._unindex))
 
     def _apply_index(self, request, cid=''):
         """ hook for (Z)Catalog




More information about the Zope-Checkins mailing list