From 643fe8db4df4d3167d3bea042966caea04eb56a9 Mon Sep 17 00:00:00 2001 From: helmutm Date: Sun, 6 Jun 2010 14:13:15 +0000 Subject: [PATCH] add more configuration options; implement default checking of query criteria git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3888 fd906abe-77d9-0310-91a1-e0d9ade77398 --- composer/report/base.py | 11 +++++++++++ composer/report/field.py | 6 +++++- composer/report/result.py | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/composer/report/base.py b/composer/report/base.py index 97da106..e4cc6d7 100644 --- a/composer/report/base.py +++ b/composer/report/base.py @@ -143,6 +143,12 @@ class LeafQueryCriteria(BaseQueryCriteria, Element): self.operator = operator self.comparisonValue = comparisonValue + def check(self, obj): + value = getattr(obj, self.name, None) + if value is not None: + return value in self.comparisonValue + return True + class CompoundQueryCriteria(BaseQueryCriteria, Compound): @@ -153,3 +159,8 @@ class CompoundQueryCriteria(BaseQueryCriteria, Compound): def __init__(self, parts): self.parts = Jeep(parts) + def check(self, obj): + for p in self.parts: + if not p.check(obj): + return False + return True diff --git a/composer/report/field.py b/composer/report/field.py index 6487707..32a1424 100644 --- a/composer/report/field.py +++ b/composer/report/field.py @@ -43,6 +43,7 @@ class Field(Component): default = None instance_name = None storeData = True + renderer = 'standard' executionSteps = ['query', 'sort', 'output'] @@ -60,8 +61,11 @@ class Field(Component): def name(self): return self.__name__ + def getRawValue(self, row): + return getattr(row.context, self.name) + def getValue(self, row): - value = getattr(row.context, self.name) + value = self.getRawValue(row) if value is None: return u'' if isinstance(value, basestring): diff --git a/composer/report/result.py b/composer/report/result.py index f699903..99605f2 100644 --- a/composer/report/result.py +++ b/composer/report/result.py @@ -50,8 +50,8 @@ class ResultSet(object): self.queryCriteria = queryCriteria def getResult(self): - result = [self.rowFactory(item, self) for item in self.data - if self.queryCriteria.check(item)] + result = [self.rowFactory(item, self) for item in self.data] + result = [row for row in result if self.queryCriteria.check(row)] if self.sortCriteria: result.sort(key=lambda x: [f.getSortValue(x) for f in self.sortCriteria]) return result