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

seb seb@jamkit.com
Thu, 28 Nov 2002 08:03:42 -0500


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

Modified Files:
	PathIndex.py 
Log Message:
 - fix for #703 merged from 2.6 branch


=== Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 1.28 => 1.29 ===
--- Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py:1.28	Thu Oct  3 09:42:22 2002
+++ Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py	Thu Nov 28 08:03:11 2002
@@ -23,6 +23,7 @@
 from BTrees.OOBTree import OOBTree
 from BTrees.IIBTree import IISet, intersection, union
 from OFS.SimpleItem import SimpleItem
+from zLOG import LOG, ERROR
 from types import StringType, ListType, TupleType
 import re, warnings
 
@@ -141,21 +142,30 @@
         """ hook for (Z)Catalog """
 
         if not self._unindex.has_key(documentId):
+            LOG(self.__class__.__name__, ERROR,
+                'Attempt to unindex nonexistent document'
+                ' with id %s' % documentId)
             return
-
+        
         path = self._unindex[documentId]
         comps = path.split('/')
 
         for level in range(len(comps[1:])):
             comp = comps[level+1]
 
-            self._index[comp][level].remove(documentId)
+            try:
+                self._index[comp][level].remove(documentId)
+
+                if len(self._index[comp][level])==0:
+                    del self._index[comp][level]
 
-            if len(self._index[comp][level])==0:
-                del self._index[comp][level]
+                if len(self._index[comp])==0:
+                    del self._index[comp]
+            except KeyError:
+                LOG(self.__class__.__name__, ERROR,
+                    'Attempt to unindex document'
+                    ' with id %s failed' % documentId)
 
-            if len(self._index[comp])==0:
-                del self._index[comp]
 
         del self._unindex[documentId]
 
@@ -209,14 +219,13 @@
 
             results = []
             for i in range(len(comps)):
-
                 comp = comps[i]
 
                 if not self._index.has_key(comp): return IISet()
                 if not self._index[comp].has_key(level+i): return IISet()
 
                 results.append( self._index[comp][level+i] )
-
+            
             res = results[0]
 
             for i in range(1,len(results)):