extend row stuff: group fields, 'useRowProperty' attribute handler
This commit is contained in:
parent
2058dcbf6a
commit
7fafd9dccd
1 changed files with 27 additions and 5 deletions
|
@ -20,13 +20,13 @@
|
|||
Report result sets and related classes.
|
||||
"""
|
||||
|
||||
from copy import copy
|
||||
from zope.cachedescriptors.property import Lazy
|
||||
|
||||
from cybertools.composer.interfaces import IInstance
|
||||
from cybertools.composer.report.base import BaseQueryCriteria
|
||||
|
||||
|
||||
|
||||
class BaseRow(object):
|
||||
|
||||
def __init__(self, context, parent):
|
||||
|
@ -35,10 +35,6 @@ class BaseRow(object):
|
|||
self.data = {}
|
||||
self.sequenceNumber = 0
|
||||
|
||||
def xx__getattr__(self, attr):
|
||||
f = self.parent.context.fields[attr]
|
||||
return f.getValue(self)
|
||||
|
||||
def getRawValue(self, attr):
|
||||
return self.data.get(attr)
|
||||
|
||||
|
@ -54,6 +50,32 @@ class Row(BaseRow):
|
|||
def getContextAttr(obj, attr):
|
||||
return getattr(obj.context, attr)
|
||||
|
||||
def getGroupFields(self):
|
||||
return [self.getRawValue(f.name) for f in
|
||||
self.parent.context.fields if 'group' in f.executionSteps]
|
||||
|
||||
@Lazy
|
||||
def displayedColumns(self):
|
||||
return self.parent.context.getActiveOutputFields()
|
||||
|
||||
def useRowProperty(self, attr):
|
||||
return getattr(self, attr)
|
||||
|
||||
|
||||
class GroupHeaderRow(BaseRow):
|
||||
|
||||
def getRawValue(self, attr):
|
||||
return self.data.get(attr, u'')
|
||||
|
||||
@Lazy
|
||||
def displayedColumns(self):
|
||||
fields = self.parent.context.getActiveOutputFields()
|
||||
for col in self.headerColumns:
|
||||
for idx, f in enumerate(fields):
|
||||
if f.name == col.name:
|
||||
fields[idx] = col
|
||||
return fields
|
||||
|
||||
|
||||
class ResultSet(object):
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue