[Zope-Checkins] CVS: Zope2 - UnTextIndex.py:1.40
Jim Fulton
jim@digicool.com
Sat, 17 Mar 2001 13:59:03 -0500 (EST)
Update of /cvs-repository/Zope2/lib/python/SearchIndex
In directory korak:/tmp/cvs-serv28146
Modified Files:
UnTextIndex.py
Log Message:
UnTextIndexes now refer directly to their lexicons.
Added logic in conversion code to implement the rule above.
Took out some broken code to unscrew some hysterical breakage.
--- Updated File UnTextIndex.py in package Zope2 --
--- UnTextIndex.py 2001/03/17 16:11:39 1.39
+++ UnTextIndex.py 2001/03/17 18:59:03 1.40
@@ -139,8 +139,7 @@
meta_type = 'Text Index'
- def __init__(self, id, ignore_ex=None,
- call_methods=None, lexicon=None):
+ def __init__(self, id, ignore_ex=None, call_methods=None, lexicon=None):
"""Create an index
The arguments are:
@@ -167,7 +166,9 @@
## if no lexicon is provided, create a default one
self._lexicon = Lexicon()
else:
- self._lexicon = lexicon
+ # We need to hold a reference to the lexicon, since we can't
+ # really change lexicons.
+ self._lexicon = self.getLexicon(lexicon)
def getLexicon(self, vocab_id):
@@ -180,10 +181,6 @@
if type(vocab_id) is not StringType:
vocab = vocab_id # we already havd the lexicon
-
- # Through some sick hysterical accident, some lexicons
- # simply wrap other lexicons, unless they don't. Waaaaaa.
- vocab = getattr(vocab, 'lexicon', vocab)
return vocab
else:
vocab = getattr(self, vocab_id)
@@ -204,6 +201,11 @@
self._unindex = IOBTree()
def _convertBTrees(self, threshold=200):
+
+ if type(self._lexicon) is type(''):
+ # Turn the name reference into a hard reference.
+ self._lexicon=self.getLexicon(self._lexicon)
+
if type(self._index) is IOBTree: return
from BTrees.convert import convert