[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/PathIndex - PathIndex.py:1.25.6.4
seb
seb@jamkit.com
Thu, 28 Nov 2002 07:15:17 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/PathIndex
In directory cvs.zope.org:/tmp/cvs-serv1003/lib/python/Products/PluginIndexes/PathIndex
Modified Files:
Tag: Zope-2_6-branch
PathIndex.py
Log Message:
- Collector #703: KeyErrors raised when unindexing a PathIndex should
be swallowed and logged.
=== Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 1.25.6.3 => 1.25.6.4 ===
--- Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py:1.25.6.3 Thu Oct 3 09:45:20 2002
+++ Zope/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py Thu Nov 28 07:15:16 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]