[ZPT] passing a list argument from ZPT to python ...
Dieter Maurer
dieter at handshake.de
Fri Feb 18 15:12:29 EST 2005
erik vogan wrote at 2005-2-17 13:10 -0500:
> ...
> if they press the "Yes" button, then the ZPT page is supposed to
>pass the same (python) list (again, ['24', '28']) to another python
>procedure that takes the desired action. however, instead of passing
>a list the ZPT page is passing a string (like: "['24', '28']").
This is not a problem of ZPT but of HTML.
Note, that *ALL* values passed on from HTML are strings.
Zope uses special name suffixes for form data to
convert and package the data again. You find
an introduction in
<http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html>
In your special case, you must represent the list in your HTML
by a sequence of (probably hidden) form variables of the
form:
<input type=hidden name="mylist:tokens:default" />
<input type=hidden name="mylist:list" value="list_element_1" />
...
<input type=hidden name="mylist:list" value="list_element_n" />
The ":tokens:default" initializes "mylist" to the empty list
in case there are no list elements. If there are list
elements, it is ignored.
The ":list" tells ZPublisher to collect the values into a list.
Of course, you would use a "tal:repeat" to generate
the sequence of "input" tags for you list values.
--
Dieter
More information about the ZPT
mailing list