Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Context object list and controllers + html
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
gazza  
View profile   Translate to Translated (View Original)
 More options 9 Nov, 15:07
From: gazza <burslem2...@yahoo.com>
Date: Mon, 9 Nov 2009 07:07:05 -0800 (PST)
Local: Mon 9 Nov 2009 15:07
Subject: Context object list and controllers + html
Hello,

I am passing a context object which is a list of objects to a html
page. Within the page I then
cycle through the objects and display them. Pretty trivial. However I
want to pass the list of objects back to the controller so I can
continue to manipulate the objects.

I though I could embed a hidden like:

<INPUT TYPE=hidden NAME=listitems VALUE=c.chosenList>

I am having problems doing this and unsure if this is the correct
approach? Clarification and enlightenment is needed on this and much
appreciate the help.

Thanks,
gazza


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Vanasco  
View profile   Translate to Translated (View Original)
 More options 9 Nov, 17:46
From: Jonathan Vanasco <jonat...@findmeon.com>
Date: Mon, 9 Nov 2009 09:46:22 -0800 (PST)
Local: Mon 9 Nov 2009 17:46
Subject: Re: Context object list and controllers + html

<INPUT TYPE="hidden" NAME="listitems" VALUE="${c.chosenList"} />


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
gazza  
View profile   Translate to Translated (View Original)
 More options 9 Nov, 22:47
From: gazza <burslem2...@yahoo.com>
Date: Mon, 9 Nov 2009 14:47:27 -0800 (PST)
Local: Mon 9 Nov 2009 22:47
Subject: Re: Context object list and controllers + html

Unfortunately I'm not seeing what I expect to see. I want to retrieve
the list of objects

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
]

Its look each item is a single character?

How do you pass a context object containing a list of items to an html
page and preserve the list of objects within the context object to be
then
passed back to the controller? Is it possible?

I apologise in advance on any confusion on this.

Thanks,
Garyc

On Nov 9, 11:46 am, Jonathan Vanasco <jonat...@findmeon.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Feifarek  
View profile   Translate to Translated (View Original)
 More options 9 Nov, 23:03
From: Matt Feifarek <matt.feifa...@gmail.com>
Date: Mon, 9 Nov 2009 17:03:15 -0600
Local: Mon 9 Nov 2009 23:03
Subject: Re: Context object list and controllers + html

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?


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Vanasco  
View profile   Translate to Translated (View Original)
 More options 10 Nov, 00:01
From: Jonathan Vanasco <jonat...@findmeon.com>
Date: Mon, 9 Nov 2009 16:01:18 -0800 (PST)
Local: Tues 10 Nov 2009 00:01
Subject: Re: Context object list and controllers + html
sorry for the confusion above.

Anything put into the "c" variable in a controller is accessible
throughout the request by Controllers and Views(templates)

${} is shorthand for "print the result of the brackets

Assuming that c.listitems is an array of list item ids, in your
template you can do:

<INPUT TYPE="hidden" NAME="listitems" VALUE="${ ','.join
(c.listitems) } " />
or
% for i in c.listitems:
    <INPUT TYPE="hidden" NAME="listitems" VALUE="${i} " />
% endfor

if c.listitems is an array of objects, you might do:
% for i in c.listitems:
    <INPUT TYPE="hidden" NAME="listitems" VALUE="${i.id} " />
% endfor

You should read through the tutorial and possibly the Mako templating
docs themselves.  All of this information is explained in there.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
gazza  
View profile   Translate to Translated (View Original)
 More options 10 Nov, 01:22
From: gazza <burslem2...@yahoo.com>
Date: Mon, 9 Nov 2009 17:22:42 -0800 (PST)
Local: Tues 10 Nov 2009 01:22
Subject: Re: Context object list and controllers + html
Much appreciated the responses.
 % for i in c.listitems:

>     <INPUT TYPE="hidden" NAME="listitems" VALUE="${i} " />
> % endfor

The above was the approach I thought about but this looks a wee' bit
verbose creating multiple instances
. Instead I think I will limit the passing of context objects to be no
more than a single element and push the list into
a DB which it will eventually end up.

Thanks,
Gazza

On Nov 9, 6:01 pm, Jonathan Vanasco <jonat...@findmeon.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google