[Zope-Checkins] CVS: Zope2 - TextIndex.py:1.1.2.24
andreas@serenade.digicool.com
andreas@serenade.digicool.com
Fri, 25 May 2001 10:00:30 -0400
Update of /cvs-repository/Zope2/lib/python/Products/PluginIndexes/TextIndex
In directory serenade:/tmp/cvs-serv31528
Modified Files:
Tag: ajung-dropin-registry
TextIndex.py
Log Message:
Vocabulary can now be choosen through the ZMI
--- Updated File TextIndex.py in package Zope2 --
--- TextIndex.py 2001/05/25 13:07:16 1.1.2.23
+++ TextIndex.py 2001/05/25 14:00:29 1.1.2.24
@@ -192,18 +192,30 @@
self.vocabulary_id = "Vocabulary"
self._lexicon = None
- if lexicon is None:
- ## if no lexicon is provided, create a default one
- self._lexicon = Lexicon()
- else:
+ if lexicon is not None:
+
# We need to hold a reference to the lexicon, since we can't
# really change lexicons.
- self._lexicon = None
+ self._lexicon = lexicon
+ self.vocabulary_id = '__userdefined__'
def getLexicon(self, vocab_id=None):
"""Return the Lexicon in use. Removed lots of stinking code"""
+ if self._lexicon is None:
+ ## if no lexicon is provided, create a default one
+ try:
+ self._lexicon = self.aq_parent.aq_parent[self.vocabulary_id].getLexicon()
+ print 'got it from parent'
+ except:
+ self._lexicon = Lexicon()
+ self.vocabulary_id = '__intern__'
+ print 'Creating my own lexicon'
+
+ return self._lexicon
+
+
if self._lexicon:
return self._lexicon
else:
@@ -216,8 +228,9 @@
def clear(self):
"""Reinitialize the text index."""
- self._index = IOBTree()
+ self._index = IOBTree()
self._unindex = IOBTree()
+ self._lexicon = None
def _convertBTrees(self, threshold=200):