provide a default comparison value that is used for querying if no comparison value has been entered for a field

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@4210 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2011-03-31 11:55:09 +00:00
parent 51b53f3169
commit 9345efa7a6
2 changed files with 9 additions and 8 deletions

View file

@ -1,5 +1,5 @@
#
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -152,9 +152,11 @@ class LeafQueryCriteria(BaseQueryCriteria, Element):
self.field = field
def check(self, row):
#if not self.comparisonValue:
if self.comparisonValue in (None, '',):
return True
comparisonValue = self.comparisonValue
if comparisonValue in (None, '',):
comparisonValue = self.field.defaultComparisonValue
if comparisonValue in (None, '',):
return True
value = self.field.getSelectValue(row)
op = operators.get(self.operator)
if op is None:
@ -162,11 +164,10 @@ class LeafQueryCriteria(BaseQueryCriteria, Element):
if op is None:
# TODO: log warning
return True
#print '***', self.field.name, repr(value), op, repr(self.comparisonValue)
return op(value, self.comparisonValue)
return op(value, comparisonValue)
def showComparisonValue(self):
if self.field.fieldType == 'selection':
if self.field.fieldType == 'selection' and self.comparisonValue:
return ', '.join([v for v in self.comparisonValue])
return self.comparisonValue

View file

@ -41,7 +41,7 @@ class Field(Component):
fieldType = 'text'
vocabulary = None
default = None
default = defaultComparisonValue = None
instance_name = None
storeData = True
renderer = 'standard'