Commit f396922c authored by Tim Peters's avatar Tim Peters

clear(): was ignoring the index_factory passed to the constructor,

reinitializing to the global Index even if that wasn't how the object
was constructed.
parent 91bf7475
...@@ -61,7 +61,8 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem): ...@@ -61,7 +61,8 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
% lexicon.getId() % lexicon.getId()
self.lexicon = lexicon self.lexicon = lexicon
self.index = index_factory(self.lexicon) self._index_factory = index_factory
self.clear()
## Pluggable Index APIs ## ## Pluggable Index APIs ##
...@@ -103,7 +104,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem): ...@@ -103,7 +104,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
chooser = NBest(nbest) chooser = NBest(nbest)
chooser.addmany(results.items()) chooser.addmany(results.items())
return chooser.getbest(), len(results) return chooser.getbest(), len(results)
def numObjects(self): def numObjects(self):
"""Return number of object indexed""" """Return number of object indexed"""
return self.index.length() return self.index.length()
...@@ -119,7 +120,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem): ...@@ -119,7 +120,7 @@ class ZCTextIndex(Persistent, Acquisition.Implicit, SimpleItem):
def clear(self): def clear(self):
"""reinitialize the index""" """reinitialize the index"""
self.index = Index(self.lexicon) self.index = self._index_factory(self.lexicon)
def _get_object_text(self, obj): def _get_object_text(self, obj):
x = getattr(obj, self._fieldname) x = getattr(obj, self._fieldname)
......
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