cybertools.reporter basically working

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@1759 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2007-05-21 10:06:03 +00:00
parent 4ac0a16080
commit 5c1a1a3544
4 changed files with 12 additions and 8 deletions

View file

@ -42,12 +42,14 @@ empty.
>>> list(r1.cells) >>> list(r1.cells)
[] []
So let's assign a schema to the result set.
>>> from cybertools.composer.schema.schema import Schema >>> from cybertools.composer.schema.schema import Schema
>>> from cybertools.composer.schema.field import Field >>> from cybertools.composer.schema.field import Field
>>> rset.schema = Schema(Field(u'firstName'), Field(u'lastName'), Field(u'birthDate')) >>> rset.schema = Schema(Field(u'firstName'), Field(u'lastName'), Field(u'birthDate'))
>>> r1 = rset.rows.next() >>> r1 = rset.rows.next()
>>> [c.text for c in r1.cells] >>> [c.text for c in r1.cells]
['Smith', 'John', '1956-08-01'] [u'Smith', u'John', u'1956-08-01']
For the browser presentation we can also use a browser view providing For the browser presentation we can also use a browser view providing
the result set with extended attributes: the result set with extended attributes:

View file

@ -17,7 +17,7 @@
<h2 tal:content="item/title">Something</h2><br /> <h2 tal:content="item/title">Something</h2><br />
<table class="listing"> <table class="listing">
<tr> <tr>
<th tal:repeat="field result/schema" <th tal:repeat="field result/schema/fields"
tal:content="field/title" tal:content="field/title"
i18n:translate="">Fieldname</th> i18n:translate="">Fieldname</th>
</tr> </tr>
@ -25,7 +25,7 @@
<tal:item define="class python: repeat['row'].odd() and 'even' or 'odd'"> <tal:item define="class python: repeat['row'].odd() and 'even' or 'odd'">
<tr tal:attributes="class class"> <tr tal:attributes="class class">
<td valign="top" <td valign="top"
repeat="cell row/cells"> tal:repeat="cell row/cells">
<a href="#" <a href="#"
tal:omit-tag="not:cell/url" tal:omit-tag="not:cell/url"
tal:attributes="href cell/url; tal:attributes="href cell/url;

View file

@ -26,6 +26,7 @@ from zope import interface, component
from zope.app.pagetemplate import ViewPageTemplateFile from zope.app.pagetemplate import ViewPageTemplateFile
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from cybertools.reporter.resultset import ResultSet
from loops.browser.common import BaseView from loops.browser.common import BaseView
@ -38,7 +39,7 @@ class DetailView(BaseView):
@Lazy @Lazy
def macro(self): def macro(self):
return self.template.macros('detail') return self.template.macros['detail']
@Lazy @Lazy
def resultSet(self): def resultSet(self):
@ -56,10 +57,9 @@ class ListingView(BaseView):
@Lazy @Lazy
def macro(self): def macro(self):
return self.template.macros('listing') return self.template.macros['listing']
@Lazy @Lazy
def resultSet(self): def resultSet(self):
result = ResultSet() return ResultSet(self.context)
return result

View file

@ -44,7 +44,9 @@ class Cell(object):
@property @property
def text(self): def text(self):
return str(self.value) if isinstance(self.value, unicode):
return self.value
return unicode(str(self.value))
@property @property
def token(self): def token(self):