diff --git a/composer/report/field.py b/composer/report/field.py index cdfc4a9..84c6091 100644 --- a/composer/report/field.py +++ b/composer/report/field.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2011 Helmut Merz helmutm@cy55.de +# Copyright (c) 2012 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 @@ -18,8 +18,6 @@ """ Implementation of report field definitions. - -$Id$ """ from datetime import datetime @@ -93,6 +91,14 @@ class Field(Component): #return self.getValue(row) +class CalculatedField(Field): + + def getRawValue(self, row): + return getattr(row, self.name) + + +# sample field + label = Field('label', u'Label', u'A short text that identifies a row for humans.') diff --git a/composer/report/result.py b/composer/report/result.py index 7055c40..5b3a13a 100644 --- a/composer/report/result.py +++ b/composer/report/result.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2010 Helmut Merz helmutm@cy55.de +# Copyright (c) 2012 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 @@ -33,6 +33,7 @@ class BaseRow(object): self.context = context self.parent = parent self.data = {} + self.sequenceNumber = 0 def __getattr__(self, attr): f = self.parent.context.fields[attr] @@ -54,7 +55,6 @@ class Row(BaseRow): return getattr(obj.context, attr) - class ResultSet(object): def __init__(self, context, data, rowFactory=Row, @@ -71,6 +71,8 @@ class ResultSet(object): 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]) + for idx, row in enumerate(result): + row.sequenceNumber = idx + 1 return result def __iter__(self): diff --git a/composer/schema/grid/grid_macros.pt b/composer/schema/grid/grid_macros.pt index 751e627..aaf16f7 100755 --- a/composer/schema/grid/grid_macros.pt +++ b/composer/schema/grid/grid_macros.pt @@ -42,37 +42,43 @@ tal:define="fieldInstance python: field.getFieldInstance(view.instance); columns fieldInstance/columnTypes; rows data/?name"> -
Column Title | |
---|---|
- + | + name string:$name.$cname:records; + style string:width: ${column/baseField/width|string:auto};" />|
+ | + tal:attributes="name string:$name.$cname:records; + style string:width: ${column/baseField/width|string:auto};" /> |