[Zope-Checkins] CVS: Zope2 - TextIndex.py:1.1.2.23

andreas@serenade.digicool.com andreas@serenade.digicool.com
Fri, 25 May 2001 09:07:16 -0400


Update of /cvs-repository/Zope2/lib/python/Products/PluginIndexes/TextIndex
In directory serenade:/tmp/cvs-serv31358

Modified Files:
      Tag: ajung-dropin-registry
	TextIndex.py 
Log Message:
vocab handling reworked



--- Updated File TextIndex.py in package Zope2 --
--- TextIndex.py	2001/05/24 20:17:06	1.1.2.22
+++ TextIndex.py	2001/05/25 13:07:16	1.1.2.23
@@ -190,6 +190,7 @@
         self.clear()
 
         self.vocabulary_id = "Vocabulary"
+        self._lexicon = None
 
         if lexicon is None:
             ## if no lexicon is provided, create a default one
@@ -197,23 +198,21 @@
         else:
             # We need to hold a reference to the lexicon, since we can't
             # really change lexicons.
-            self._lexicon = lexicon
+            self._lexicon = None
 
 
     def getLexicon(self, vocab_id=None):
         """Return the Lexicon in use. Removed lots of stinking code"""
-#        print self.aq_parent.aq_parent.objectItems('Vocabulary')
-        return self._lexicon.lexicon
 
+        if self._lexicon:
+            return self._lexicon
+        else:
+            return self.aq_parent.aq_parent[self.vocabulary_id].getLexicon()
+
 
     def __nonzero__(self):
         return not not self._unindex
     
-    # Too expensive
-    #def __len__(self):
-    #    """Return the number of objects indexed."""
-    #    return len(self._unindex)
-
 
     def clear(self):
         """Reinitialize the text index."""
@@ -686,9 +685,13 @@
                                REQUEST=None,RESPONSE=None,URL2=None):
         """ preferences of TextIndex """
 
-#        self.useSplitter = splitter
+#       self.useSplitter = splitter
 #       self.useOperator = text_operator
-        self.vocabulary_id    = vocabulary
+
+        if self.vocabulary_id != vocabulary:
+            self.clear()
+            self.vocabulary_id    = vocabulary
+
         print self.vocabulary_id
 
         if RESPONSE: