[Zope-Checkins] CVS: Zope2 - UnIndex.py:1.1.2.8
andreas@serenade.digicool.com
andreas@serenade.digicool.com
Tue, 22 May 2001 13:40:41 -0400
Update of /cvs-repository/Zope2/lib/python/Products/PluginIndexes/common
In directory serenade:/tmp/cvs-serv19384/common
Modified Files:
Tag: ajung-dropin-registry
UnIndex.py
Log Message:
Code cleanup
--- Updated File UnIndex.py in package Zope2 --
--- UnIndex.py 2001/05/21 14:54:37 1.1.2.7
+++ UnIndex.py 2001/05/22 17:40:41 1.1.2.8
@@ -100,6 +100,7 @@
from BTrees.IIBTree import IITreeSet, IISet, union, intersection
import BTrees.Length
+from Products.PluginIndexes.common.util import parseIndexRequest
import sys,exceptions
_marker = []
@@ -376,54 +377,34 @@
up in a tuple ala: request = {'id':('',)}
"""
- id = self.id #name of the column
- cidid = "%s/%s" % (cid,id)
+ record = parseIndexRequest(request,self.id)
+ if record.keys==None: return None
- # i have no f'ing clue what this cdid stuff is for - chrism
- if request.has_key(cidid):
- keys = request[cidid]
- elif request.has_key(id):
- keys = request[id]
- else:
- return None
-
- if type(keys) not in (ListType, TupleType):
- if keys == '':
- return None
- else:
- keys = [keys]
-
index = self._index
- r = None
- opr = None
+ r = None
+ opr = None
- # experimental code for specifing the operator
- if request.has_key(id+"_operator"):
- # check if someone overrides the "or" parameter
- # for combining search results
- operator = request[id+"_operator"].lower()
- if not operator in self.operators :
- raise exepctions.RuntimeError,"operator not valid: %s" % operator
- else:
- operator = self.useOperator
+ # experimental code for specifing the operator
+ operator = record.get('operator',self.useOperator)
+ if not operator in self.operators :
+ raise exepctions.RuntimeError,"operator not valid: %s" % operator
- # depending on the operator we use intersection of union
+ # depending on the operator we use intersection or union
if operator=="or": set_func = union
else: set_func = intersection
-
- if request.has_key(id+'_usage'):
+ if record.get('usage',None):
# see if any usage params are sent to field
- opr=string.split(string.lower(request[id+"_usage"]),':')
+ opr = record.usage.lower().split(':')
opr, opr_args=opr[0], opr[1:]
if opr=="range": # range search
- if 'min' in opr_args: lo = min(keys)
+ if 'min' in opr_args: lo = min(record.keys)
else: lo = None
- if 'max' in opr_args: hi = max(keys)
+ if 'max' in opr_args: hi = max(record.keys)
else: hi = None
if hi:
setlist = index.items(lo,hi)
@@ -435,7 +416,7 @@
set = IISet((set,))
r = set_func(r, set)
else: # not a range search
- for key in keys:
+ for key in record.keys:
set=index.get(key, None)
if set is not None:
if type(set) is IntType:
@@ -444,9 +425,9 @@
if type(r) is IntType: r=IISet((r,))
if r is None:
- return IISet(), (id,)
+ return IISet(), (self.id,)
else:
- return r, (id,)
+ return r, (self.id,)
def hasUniqueValuesFor(self, name):
' has unique values for column NAME '