Commit 279c466f authored by Evan Simpson's avatar Evan Simpson

Merge bugfix from Zope-2_4-branch

parent f2d64fb7
......@@ -87,7 +87,7 @@
"""
__version__ = '$Revision: 1.13 $'[11:-2]
__version__ = '$Revision: 1.14 $'[11:-2]
import string, re
......@@ -202,6 +202,8 @@ class TextIndex(PluggableIndex.PluggableIndex, Persistent,
self._lexicon = None
if lexicon is not None:
......@@ -700,7 +702,6 @@ class TextIndex(PluggableIndex.PluggableIndex, Persistent,
else: i = i + 1
if (len(query) != 1):
import pdb; pdb.set_trace()
raise QueryError, "Malformed query"
return query[0]
......@@ -748,13 +749,14 @@ def parse(s):
def parse2(q, default_operator, operator_dict=operator_dict):
"""Find operators and operands"""
isop = operator_dict.has_key
i = len(q) - 1
while i >= 0:
i = 0
while i < len(q):
e = q[i]
if isinstance(e, ListType):
q[i] = parse2(e, default_operator)
if i % 2:
q.insert(i, default_operator)
i = i + 1
elif i % 2:
# This element should be an operator
if isop(e):
......@@ -763,7 +765,8 @@ def parse2(q, default_operator, operator_dict=operator_dict):
else:
# Insert the default operator.
q.insert(i, default_operator)
i = i - 1
i = i + 1
i = i + 1
return q
......
......@@ -233,6 +233,7 @@ class Tests(unittest.TestCase):
def testDefOrQuery(self):
"Test a default OR query"
self.globTest({'text':'time country'}, [0,1,6])
self.globTest({'text':'time good country'}, [0,1,6])
def testNearQuery(self):
"""Test a NEAR query.. (NOTE:ACTUALLY AN 'AND' TEST!!)"""
......
......@@ -91,7 +91,7 @@ undo information so that objects can be unindexed when the old value
is no longer known.
"""
__version__ = '$Revision: 1.50 $'[11:-2]
__version__ = '$Revision: 1.51 $'[11:-2]
import string, re
......@@ -684,13 +684,14 @@ def parse2(q, default_operator,
operator_dict={AndNot: AndNot, And: And, Or: Or, Near: Near}):
"""Find operators and operands"""
isop = operator_dict.has_key
i = len(q) - 1
while i >= 0:
i = 0
while i < len(q):
e = q[i]
if isinstance(e, ListType):
q[i] = parse2(e, default_operator)
if i % 2:
q.insert(i, default_operator)
i = i + 1
elif i % 2:
# This element should be an operator
if isop(e):
......@@ -699,7 +700,8 @@ def parse2(q, default_operator,
else:
# Insert the default operator.
q.insert(i, default_operator)
i = i - 1
i = i + 1
i = i + 1
return q
......
......@@ -235,6 +235,7 @@ class Tests(unittest.TestCase):
def testDefOrQuery(self):
"Test a default OR query"
self.globTest({'text':'time country'}, [0,1,6])
self.globTest({'text':'time good country'}, [0,1,6])
def testNearQuery(self):
"""Test a NEAR query.. (NOTE:ACTUALLY AN 'AND' TEST!!)"""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment