On Jan 22, 2:00 pm, Robert Kluin <[email protected]> wrote:
> You'll have to show us how you are rendering the form. If you're
> using template, just pass the value you get for type to your template
> and print the value, like djidjadji said.
Sorry, I am confused about this. The form is not rendered;
DirectorySubmitHandler handles the form submission to write the
submission to the database and then redirects to Directory which pulls
the relevant merchandise_type from database and renders it.
The url parameter is saved in Directory as
merchandise_type = self.request.get("type")
So, Python will not let me use merchandise_type in
DirectorySubmitHandler.
I don't know how I can pass merchandise_type to the form. Please let
me know what I am missing here.
<input type="hidden" name="dir_type" value="I don't know what should
go here">
I am not using templates.
I need to use merchandise_type in DirectorySubmitHandler to redirect
to Directory.
Maybe I should handle the form with Directory too, but not sure if I
can do that.
I copy the handlers below from my first post. If more information is
needed please let me know:
In the Directory handler I have
merchandise_type = self.request.get("type")
How do I use merchandise_type in the DirectorySubmitHandler?
class Directory(webapp.RequestHandler):
def get(self):
....
merchandise_type = self.request.get("type", "")
items = Item.all()
items.filter("type =", merchandise_type)
...
class DirectorySubmitHandler(webapp.RequestHandler):
def post(self):
user = users.get_current_user()
#the following line gives unknown global name error
dir_type = merchandise_type
if user:
item = Item()
item.title = self.request.get("title")
item.url = self.request.get("url")
item.type = self.request.get("dir_type")
item.user_who_liked_this_item = user
item.put()
self.redirect("/dir?type=%s" %
self.request.get("dir_type"))
else:
self.redirect(users.create_login_url(self.request.uri))
Thanks again.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" 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/google-appengine?hl=en.