On Wed, Dec 14, 2005 at 06:06:21PM +1300, Cameron Beattie wrote:
> I am trying to get my head around representing a list in a page template.
> 
> Assume the following list:
> >>>m
> [[61282125371L, 1, 6, 0], [61282125379L, 1, 6, 0], [61282825240L, 6, 6, 0], 
> [61282125378L, 1, 6, 0], [61282125374L, 1, 6, 0]
> >>>m[0]
> [61282125371L, 1, 6, 0]
> >>>m[0][0]
> 61282125371L
> 
> i.e. m is a list where each member is itself a list.
> 
> How do I get a page template to render a particular item? Assume a function 
> getem returns the list.
> <tal:block repeat="m python:here.getem()">
>    <td tal:repeat="single m" tal:content="single"></td>
> 
> This code will produce four columns and five rows, with each populated by 
> the list members. But what if I only want the first and third members in 
> each case i.e. 2 columns and five rows?
> 
> I thought it would be something like tal:content="python:single[0]" but 
> that gives me an unsubscriptable object error.

That's because, in your example, each time through the loop,
single is an int. Try indexing m instead.

-- 

Paul Winkler
http://www.slinkp.com
_______________________________________________
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to