provide operator selection for query criteria
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3922 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
3597866999
commit
828e46a447
2 changed files with 15 additions and 5 deletions
|
@ -22,6 +22,7 @@ Basic classes for report management.
|
|||
$Id$
|
||||
"""
|
||||
|
||||
import operator
|
||||
from zope.interface import implements
|
||||
|
||||
from cybertools.composer.base import Component, Element, Compound
|
||||
|
@ -147,12 +148,15 @@ class LeafQueryCriteria(BaseQueryCriteria, Element):
|
|||
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:
|
||||
if self.operator == 'in':
|
||||
return value in self.comparisonValue
|
||||
#return True
|
||||
op = getattr(operator, self.operator, None)
|
||||
if op is None:
|
||||
# TODO: log warning
|
||||
return True
|
||||
#print '***', self.field.name, value, op, self.comparisonValue
|
||||
return op(value, self.comparisonValue)
|
||||
|
||||
|
||||
class CompoundQueryCriteria(BaseQueryCriteria, Compound):
|
||||
|
|
|
@ -47,6 +47,12 @@ class Field(Component):
|
|||
|
||||
executionSteps = ['query', 'sort', 'output']
|
||||
|
||||
operators = [{'token': 'eq', 'label': '=='},
|
||||
{'token': 'lt', 'label': '<'},
|
||||
{'token': 'le', 'label': '<='},
|
||||
{'token': 'gt', 'label': '>'},
|
||||
{'token': 'ge', 'label': '>='},]
|
||||
|
||||
def __init__(self, name, title=None, fieldType='textline', **kw):
|
||||
assert name
|
||||
self.__name__ = name
|
||||
|
|
Loading…
Add table
Reference in a new issue