[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG - TextIndexNG.py:1.2.2.2
Andreas Jung
andreas@zope.com
Fri, 4 Jan 2002 15:58:16 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG
In directory cvs.zope.org:/tmp/cvs-serv27333
Modified Files:
Tag: ajung-textindexng-branch
TextIndexNG.py
Log Message:
=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/TextIndexNG.py 1.2.2.1 => 1.2.2.2 ===
from BTrees.IOBTree import IOBTree
-from BTrees.OIBTree import OIBTree
from BTrees.OOBTree import OOBTree
-from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
-from BTrees.IIBTree import difference, weightedIntersection
+from BTrees.IIBTree import IIBTree, IIBucket, IISet
+from BTrees.IIBTree import weightedIntersection
from Products.PluginIndexes.TextIndex.Lexicon import Lexicon
from Products.PluginIndexes.TextIndex.GlobbingLexicon import GlobbingLexicon
@@ -58,7 +57,8 @@
'help': ('TextIndex','TextIndex_Settings.stx')},
)
- query_options = ["query","operator"]
+ query_options = ("query","operator")
+ _valid_default_operators = ('and','or')
def __init__(self
, id
@@ -97,11 +97,19 @@
self._stemmerfunc = Stemmer.Stemmer(self.useStemmer).stem
if self.lexicon:
- self._LEXICON = self.lexicon
+
+ # try to get lexicon through acquisition
+ import pdb
+ pdb.set_trace()
+ self._LEXICON = getattr(self,self.lexicon)
+
else:
+
if self.useGlobbing:
+
self._LEXICON = GlobbingLexicon()
debug('created new globbing lexicon')
+
if self._stemmerfunc:
debug('stemming disabled because globbing enabled')
self._stemmerfunc = None
@@ -117,7 +125,13 @@
def __nonzero__(self):
return not not self._unindex
-
+
+ def defaultOperators(self):
+ return self._valid_default_operators
+
+ def availableStemmers(self):
+ return Stemmer.availableStemmers()
+
def insertForwardEntry(self,wordId,pos,documentId):
@@ -146,6 +160,7 @@
for k,v in self._IDX[wordId].items():
print k,v
+
def index_object(self, documentId, obj, threshold=None):
try:
@@ -424,11 +439,32 @@
return len(self._IDX)
+
def manage_setPreferences(self,extra,
REQUEST=None,RESPONSE=None,URL2=None):
""" preferences of TextIndex """
- pass
+ for x in ('useOperator','useGlobbing',\
+ 'useNearSearch','useSplitter','useStemmer'):
+
+ changed = 0
+
+ if hasattr(extra,x):
+
+ oldval = getattr(self,x)
+ newval = getattr(extra,x)
+ setattr(self, x, newval)
+ if oldval != newval:
+ changed = 1
+
+ if changed:
+ debug('settings changed')
+ self.clear()
+
+ if RESPONSE:
+ RESPONSE.redirect(URL2 + '/manage_main?manage_tabs_message'\
+ '=Index%20cleared,%20Preferences%20saved')
+ return
if RESPONSE:
RESPONSE.redirect(URL2 + '/manage_main?manage_tabs_message=Preferences%20saved')