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

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


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

Modified Files:
	PathIndex.py 
Log Message:
fixed potential upgrade problem due to new '_length' attribute


=== Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 1.36 => 1.37 ===
--- Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py:1.36	Sat Aug 16 12:44:42 2003
+++ Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py	Tue Nov  4 10:47:35 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