improve checking selection criteria

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3919 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2010-07-10 09:35:37 +00:00
parent afb4222532
commit 3597866999
2 changed files with 15 additions and 6 deletions

View file

@ -138,16 +138,21 @@ class LeafQueryCriteria(BaseQueryCriteria, Element):
implements(ILeafQueryCriteria)
def __init__(self, name, operator, comparisonValue):
def __init__(self, name, operator, comparisonValue, field):
self.name = name
self.operator = operator
self.comparisonValue = comparisonValue
self.field = field
def check(self, obj):
value = getattr(obj, self.name, None)
if value is not None:
return value in self.comparisonValue
return True
def check(self, row):
if not self.comparisonValue:
return True
#value = getattr(row, self.name, None)
value = self.field.getSelectValue(row)
#print '***', self.name, self.operator, self.comparisonValue, value
#if value is not None:
return value in self.comparisonValue
#return True
class CompoundQueryCriteria(BaseQueryCriteria, Compound):

View file

@ -64,6 +64,10 @@ class Field(Component):
def getRawValue(self, row):
return getattr(row.context, self.name)
def getSelectValue(self, row):
return getattr(row, self.name, None)
#return self.getRawValue(row)
def getValue(self, row):
value = self.getRawValue(row)
if value is None: