Re: passing a list argument from ZPT to python ...

Dieter Maurer <[email protected]>
Newsgroups gmane.comp.web.zope.page-templates
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.