[Zope] Re: ZPT with Zope 3 queries - repeat over contained items

Tres Seaver tseaver at palladion.com
Tue Jul 5 08:22:57 EDT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jim Vine wrote:
> 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"

Likely, 'context' is a dict, or a workalike, whose 'items' method
returns a sequence of tuples.  Therefore, during the tal:repeat, 'item'
is a tuple, (key, value).

Try using 'values' instead of 'items'.


Tres.
- --
===================================================================
Tres Seaver          +1 202-558-7113          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCynuh+gerLs4ltQ4RAl5uAKCRzRzV+g1M8gcbV07jSNfCQbWbhgCg0nL4
2POVN4oUQepYUIQ+pR1IPRU=
=fBFx
-----END PGP SIGNATURE-----



More information about the Zope mailing list