diff --git a/composer/report/field.py b/composer/report/field.py index 4debe38..6257e00 100644 --- a/composer/report/field.py +++ b/composer/report/field.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 @@ -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 9af877f..4401563 100644 --- a/composer/report/result.py +++ b/composer/report/result.py @@ -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] @@ -71,6 +72,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):