On Mon, Nov 9, 2009 at 4:47 PM, gazza <[email protected]> wrote:
>
> from the c.chosenList:
>
> say the list is<2,4>
>
> <INPUT TYPE="hidden" NAME="listitems" VALUE="${c.chosenList}" />
>
> Within testController:
>
> def test(self,id):
> locallist = request.params.get("listitems")
> for index,item in enumerate(locallist):
> print "%s",item
>
> I was expecting it to obtain pass the original list and index through
> through it. Instead I see the below
> [
> 2
> ,
> 4
> ]
>
When you put ${c.chosenList} into your output template, it's no longer
python; it's part of your html string; your html page would look like this:
<INPUT TYPE="hidden" NAME="listitems" VALUE="[2, 4]" />
When that is posted back to the server, it simply comes in as a string: "[2,
4]". If you want to "parse" that string into a python object, you'll have to
do that in your controller, or perhaps with FormEncode.
If you're trying to send multiple values in your form, you'll need multiple
form elements... like a checkbox set. Those kinds of form elements can send
multiple values, and that will be reflected in request.params.
The key concept is that HTML doesn't understand anything about Python
variables... how could it?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---