[ZPT] TALES: how to access a list?

Brent Hendricks brentmh@ece.rice.edu
Tue, 9 Oct 2001 10:16:32 -0500


My apologies if this was answered already, but I didn't see it...

On Thu, Oct 04, 2001 at 03:20:24PM +0200, Raymond Penners wrote:
> What I want to accomplish is the following: I have a form with a number 
> of input fields, whose values are recorded as a list:
> 
> <li tal:repeat="num python:range(10)">
>   <input type="text" name="mylist:list" value=""
>     tal:attributes="value FIXME">
> </li>

I think the problem is that you're approcahing this from the wrong
angle.  Instead of iterating over list indices, iterate over the list
items themselves:

<li tal:repeat="item request/form/myval">
  <input type="text" name="mylist:list" value=""
    tal:attributes="value item">
</li>


Hope this helps,
Brent

-------------------------------------------------------------------------

"The programmer, like the poet, works only slightly removed from pure
 thought-stuff.  He builds his castles in the air, from air, creating
 by exertion of the imagination.  Few media of creation are so
 flexible, so easy to polish and rework, so readily capable of
 realizing grand conceptual structures."
                        -- Frederick Brooks, Jr., The Mythical Man Month