[Zope] ZPT with Zope 3 queries - repeat over contained items
Jim Vine
jim_a_vine at yahoo.co.uk
Mon Jul 4 16:09:58 EDT 2005
Hello,
Re-reading this, I realised I'd not provided much
information on the "repeat" problem, so I'm filling in
some gaps.
This works as I would expect:
<table border="1" width="80%">
<tr>
<th>Number</th>
</tr>
<tr tal:repeat="item context/items">
<td tal:content="repeat/item/number">#</td>
</tr>
</table>
i.e., if it is repeating over a property folder with
four objects in it, it produces a table headed
"Number" and with 4 further rows with numbers 1, 2, 3,
and 4 in.
However, as soon as I add any meat to it, e.g.:
<table border="1" width="80%">
<tr>
<th>Number</th>
<th>Name</th>
</tr>
<tr tal:repeat="item context/items">
<td tal:content="repeat/item/number">#</td>
<td tal:content="item/Name">Name</td>
</tr>
</table>
I get an error which shows up on the error log as:
"TypeError: tuple indices must be integers"
I have tried the second <td> element as all sorts:
<td tal:content="item/name">Name</td>
and:
<td tal:content="item/title">Name</td>
and:
<td tal:content="item/getId">Name</td>
and:
<td tal:content="item/street">Name</td>
(all of the objects in the PropertyFolder have a
"street" attribute)
These all give the same error. Since my simple test
case works, it seems like I'm setting the loop up
correctly, but am asking for the data in the wrong way
later on. getId and title certainly look from the Zope
2.6 book like they should work, and I tried the rest
as "guesses". Where should I be looking to find the
correct information on how to do this in Zope 3?
Thanks,
Jim
> Hello,
>
> I'm building an application in Zope 3. I have a
> container object called a PropertyFolder, which
> holds
> Property objects.
>
> * Repeating over contained items.
>
> I'm trying to create a view which displays a list of
> all the Property objects in a property folder. I've
> tried doing this as described in the ZPT chapter of
> the Zope Book (2.6 edition), using a tal:repeat
> statement, but I can't seem to get it working. Has
> something changed in Zope 3? I've tried looking in
> the
> Zope 3 book, but none of the references to
> tal:repeat
> in there seem to be used for this type of thing.
>
___________________________________________________________
How much free photo storage do you get? Store your holiday
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
More information about the Zope
mailing list