Commit 4593245a authored by Chris McDonough's avatar Chris McDonough

Committing zcatatalog keyerror fixes to trunk.

parent 9033fe63
......@@ -385,24 +385,28 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
Note, the uid must be the same as when the object was
catalogued, otherwise it will not get removed from the catalog
This method should not raise an exception if the uid cannot
be found in the catalog.
"""
try:
rid = self.uids[uid]
data = self.data
uids = self.uids
paths = self.paths
indexes = self.indexes
rid = uids.get(uid, None)
for x in self.indexes.values():
if rid is not None:
for x in indexes.values():
x = x.__of__(self)
if hasattr(x, 'unindex_object'):
try:
x.unindex_object(rid)
except KeyError:
pass #fugedaboudit
del self.data[rid]
del self.uids[uid]
del self.paths[rid]
except:
pass
x.unindex_object(rid)
# this should never raise an exception
for btree in (data, paths):
try:
del btree[rid]
except KeyError:
pass
del uids[uid]
def clear(self):
""" clear catalog """
......
......@@ -84,7 +84,7 @@
##############################################################################
"""Simple column indices"""
__version__='$Revision: 1.11 $'[11:-2]
__version__='$Revision: 1.12 $'[11:-2]
from Globals import Persistent
from Acquisition import Implicit
......@@ -186,15 +186,18 @@ class UnIndex(Persistent, Implicit):
def unindex_object(self, i):
""" Unindex the object with integer id 'i' """
""" Unindex the object with integer id 'i' and don't
raise an exception if we fail """
index = self._index
unindex = self._unindex
k = unindex[i]
k = unindex.get(i, None)
if k is None:
return None
set = index.get(k)
if set is not None: set.remove(i)
set = index.get(k, None)
if set is not None:
try: set.remove(i)
except: pass
del unindex[i]
self._index = index
......
......@@ -43,16 +43,17 @@ class UnKeywordIndex(UnIndex):
def unindex_object(self, i):
""" Unindex the object with integer id 'i' """
""" carefully unindex the object with integer id 'i' and do not
fail if it does not exist """
index = self._index
unindex = self._unindex
kws = unindex[i]
kws = unindex.get(i, None)
if kws is None:
return None
for kw in kws:
set = index.get(kw)
set = index.get(kw, None)
if set is not None: set.remove(i)
del unindex[i]
......
......@@ -92,7 +92,7 @@ is no longer known.
"""
__version__='$Revision: 1.23 $'[11:-2]
__version__='$Revision: 1.24 $'[11:-2]
from Globals import Persistent
import BTree, IIBTree, IOBTree, OIBTree
......@@ -316,18 +316,23 @@ class UnTextIndex(Persistent, Implicit):
def unindex_object(self, i, tt=type(()) ):
""" unindex object 'obj' with iteger id 'i' from the text index """
""" carefully unindex document with integer id 'i' from the text
index and do not fail if it does not exist """
index = self._index
for n in self._unindex[i]:
v = index[n]
if type(v) is tt:
del index[n]
else:
del index[n][i]
del self._unindex[i]
self._index = index
unindex = self._unindex
val = unindex.get(i, None)
if val is not None:
for n in val:
v = index.get(n, None)
if type(v) is tt:
del index[n]
elif v is not None:
try:
del index[n][i]
except (KeyError, IndexError, TypeError):
pass
del unindex[i]
self._index = index
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment