Commit 2f0191b1 authored by Michel Pelletier's avatar Michel Pelletier

Indexes assumed that if a schema was present to use __getitem__ this

is not the case if an object is passed in to be indexed and does not
support __getitem__
parent c30848e9
......@@ -84,7 +84,7 @@
##############################################################################
"""Simple column indices"""
__version__='$Revision: 1.23 $'[11:-2]
__version__='$Revision: 1.24 $'[11:-2]
from Globals import Persistent
from BTree import BTree
......@@ -210,7 +210,7 @@ class Index(Persistent):
index = self._index
id = self.id
if self._schema is None:
if (self._schema is None) or (obj is not None):
f = getattr
else:
f = operator.__getitem__
......@@ -219,10 +219,14 @@ class Index(Persistent):
if obj is None:
obj = self._data[i]
if self.call_methods:
k = f(obj, id)()
else:
k = f(obj, id)
try:
if self.call_methods:
k = f(obj, id)()
else:
k = f(obj, id)
except:
pass
if k is None or k == MV: return
......
......@@ -202,7 +202,7 @@ Notes on a new text index design
space.
"""
__version__='$Revision: 1.19 $'[11:-2]
__version__='$Revision: 1.20 $'[11:-2]
from Globals import Persistent
import BTree, IIBTree
......@@ -291,7 +291,7 @@ class TextIndex(Persistent):
if 'obj' is passed in, it is indexed instead of _data[i]"""
id = self.id
if self._schema is None:
if (self._schema is None) or (obj is not None):
f = getattr
else:
f = operator.__getitem__
......@@ -300,12 +300,15 @@ class TextIndex(Persistent):
if obj is None:
obj = self._data[i]
if self.call_methods:
k = str(f(obj, id)())
else:
k = str(f(obj, id))
try:
if self.call_methods:
k = str(f(obj, id)())
else:
k = str(f(obj, id))
self._index_document(k, i ,un)
self._index_document(k, i ,un)
except:
pass
def unindex_item(self, i, obj=None):
......
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