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:
parent
afb4222532
commit
3597866999
2 changed files with 15 additions and 6 deletions
|
@ -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):
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue