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

andreas@serenade.digicool.com andreas@serenade.digicool.com
Fri, 18 May 2001 10:46:29 -0400


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

Modified Files:
      Tag: ajung-dropin-registry
	TextIndex.py 
Log Message:
fixed some )*(&)*(&)*( code



--- Updated File TextIndex.py in package Zope2 --
--- TextIndex.py	2001/05/18 14:08:59	1.1.2.11
+++ TextIndex.py	2001/05/18 14:46:29	1.1.2.12
@@ -504,6 +504,8 @@
         records.  The second object is a tuple containing the names of
         all data fields used.  
         """
+
+
         if request.has_key(self.id):
             keys = request[self.id]
         else:
@@ -511,33 +513,15 @@
 
         # Changed for 2.4
         # We use the default operator that can me managed via the ZMI
-  
-        
-        operators = {
-            'andnot':AndNot,
-            'and':And,
-            'near':Near,
-            'or':Or
-            }
-
-        query_operator = Or
-
-        print '-'*80
-        print 'old_code:',query_operator,len(query_operator),type(query_operator)
-        print 'new_code:',self.operators[self.useOperator],len(self.operators[self.useOperator]),type(self.operators[self.useOperator])
-        print 'equal', self.operators[self.useOperator]==Or
-        assert  self.operators[self.useOperator]==Or
 
-#        print dir(self)
+        query_operator = self.operators[self.useOperator]
 
-#        query_operator = self.operators[self.useOperator]
-
         # We default to 'or' if we aren't passed an operator in the request
         # or if we can't make sense of the passed-in operator
 
         if request.has_key('textindex_operator'):
             op=string.lower(str(request['textindex_operator']))
-            query_operator = operators.get(op, query_operator)
+            query_operator = self.operators.get(op, query_operator)
 
         if type(keys) is StringType:
             if not keys or not string.strip(keys):
@@ -551,7 +535,6 @@
             if not key:
                 continue
 
-            print key,query_operator
             b = self.query(key, query_operator).bucket()
             w, r = weightedIntersection(r, b)
 
@@ -620,6 +603,7 @@
 
     def get_operands(self, q, i):
         """Evaluate and return the left and right operands for an operator"""
+
         try:
             left  = q[i - 1]
             right = q[i + 1]
@@ -662,7 +646,7 @@
         # order: AndNote -> And -> Or -> Near
         i = 0
         while (i < len(query)):
-            if query[i] is AndNot:
+            if query[i] == AndNot:
                 left, right = self.get_operands(query, i)
                 val = left.and_not(right)
                 query[(i - 1) : (i + 2)] = [ val ]
@@ -670,7 +654,7 @@
 
         i = 0
         while (i < len(query)):
-            if query[i] is And:
+            if query[i] == And:
                 left, right = self.get_operands(query, i)
                 val = left & right
                 query[(i - 1) : (i + 2)] = [ val ]
@@ -678,7 +662,7 @@
 
         i = 0
         while (i < len(query)):
-            if query[i] is Or:
+            if query[i] == Or:
                 left, right = self.get_operands(query, i)
                 val = left | right
                 query[(i - 1) : (i + 2)] = [ val ]
@@ -686,7 +670,7 @@
 
         i = 0
         while (i < len(query)):
-            if query[i] is Near:
+            if query[i] == Near:
                 left, right = self.get_operands(query, i)
                 val = left.near(right)
                 query[(i - 1) : (i + 2)] = [ val ]