diff --git a/reporter/README.txt b/reporter/README.txt
index 13d7b8e..2071f09 100644
--- a/reporter/README.txt
+++ b/reporter/README.txt
@@ -35,6 +35,20 @@ then provide a listing of persons...
>>> len(list(rset.rows))
3
+As we have not yet provided a schema for the result set the rows are
+empty.
+
+ >>> r1 = rset.rows.next()
+ >>> list(r1.cells)
+ []
+
+ >>> from cybertools.composer.schema.schema import Schema
+ >>> from cybertools.composer.schema.field import Field
+ >>> rset.schema = Schema(Field(u'firstName'), Field(u'lastName'), Field(u'birthDate'))
+ >>> r1 = rset.rows.next()
+ >>> [c.text for c in r1.cells]
+ ['Smith', 'John', '1956-08-01']
+
For the browser presentation we can also use a browser view providing
the result set with extended attributes:
diff --git a/reporter/browser/macros.pt b/reporter/browser/macros.pt
index 2f342e0..390ee55 100644
--- a/reporter/browser/macros.pt
+++ b/reporter/browser/macros.pt
@@ -4,7 +4,7 @@
Something
- | Fieldname: |
Value |
@@ -27,7 +27,7 @@
Value
diff --git a/reporter/interfaces.py b/reporter/interfaces.py
index b5254a2..7c9db16 100644
--- a/reporter/interfaces.py
+++ b/reporter/interfaces.py
@@ -46,7 +46,7 @@ class IRow(Interface):
cells = Attribute(u'Mapping of data elements addressed by field names.')
- value = Attribute(u'The object that is the base of this row.')
+ context = Attribute(u'The object that is the base of this row.')
resultSet = Attribute('The result set this row belongs to.')
schema = Attribute(u'The schema of the result set this row belongs to')
@@ -56,6 +56,8 @@ class ICell(Interface):
""" A single cell of a listing or table.
"""
+ field = Attribute(u'The schema field the cell belongs to.')
+
text = Attribute(u'Text to be displayed.')
value = Attribute(u'The real object, often identical to text.')
token = Attribute(u'May be used to identify a cell within '
@@ -64,12 +66,12 @@ class ICell(Interface):
# string:${view/url}/.target${row/uniqueId}
urlTitle = Attribute(u'Optional title for this link.')
- title = Attribute('The title of the schema field this cell belongs to.')
row = Attribute('The row this cell belongs to.')
def sortKey():
""" Returns a value (typically a string or a sequence) that will
- be used for comparing cells in order to sort rows.
+ be used for comparing cells in order to sort rows on the
+ corresponding column.
"""
diff --git a/reporter/resultset.py b/reporter/resultset.py
index 8edc531..37332ff 100644
--- a/reporter/resultset.py
+++ b/reporter/resultset.py
@@ -27,6 +27,8 @@ $Id$
from zope.component import adapts
from zope.interface import implements
+
+from cybertools.composer.schema.schema import Schema
from cybertools.reporter.interfaces import IDataSource
from cybertools.reporter.interfaces import IResultSet, IRow, ICell
@@ -42,14 +44,25 @@ class Cell(object):
@property
def text(self):
- return value
+ return str(self.value)
@property
def token(self):
- return value
+ return self.value
def sortKey(self):
- return value
+ return self.value
+
+ @property
+ def url(self):
+ view = self.row.resultSet.view
+ if view is None:
+ return ''
+ return IAbsoluteURL(self.row, view.request, name=field.__name__)
+
+ @property
+ def urlTitle(self):
+ return ''
class Row(object):
@@ -57,14 +70,17 @@ class Row(object):
implements(IRow)
def __init__(self, context, resultSet):
- self.context = context # a single object (in this case)
+ self.context = context
self.resultSet = resultSet
+ @property
+ def schema(self):
+ return self.resultSet.schema
+
@property
def cells(self):
- schema = self.resultSet.schema
- for f in schema.fields:
- yield Cell(f, getattr(self.context, f.__name__), self)
+ for f in self.resultSet.schema.fields:
+ yield Cell(f, getattr(self.context, f.name), self)
class ResultSet(object):
@@ -72,11 +88,11 @@ class ResultSet(object):
implements(IResultSet)
adapts(IDataSource)
- schema = None
view = None
def __init__(self, context):
self.context = context
+ self.schema = Schema()
@property
def rows(self):
|