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 # 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 # it under the terms of the GNU General Public License as published by
@ -152,8 +152,10 @@ class LeafQueryCriteria(BaseQueryCriteria, Element):
self.field = field self.field = field
def check(self, row): def check(self, row):
#if not self.comparisonValue: comparisonValue = self.comparisonValue
if self.comparisonValue in (None, '',): if comparisonValue in (None, '',):
comparisonValue = self.field.defaultComparisonValue
if comparisonValue in (None, '',):
return True return True
value = self.field.getSelectValue(row) value = self.field.getSelectValue(row)
op = operators.get(self.operator) op = operators.get(self.operator)
@ -162,11 +164,10 @@ class LeafQueryCriteria(BaseQueryCriteria, Element):
if op is None: if op is None:
# TODO: log warning # TODO: log warning
return True return True
#print '***', self.field.name, repr(value), op, repr(self.comparisonValue) return op(value, comparisonValue)
return op(value, self.comparisonValue)
def showComparisonValue(self): 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 ', '.join([v for v in self.comparisonValue])
return self.comparisonValue return self.comparisonValue

View file

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