[google-appengine] How to use the same variable in two handlers?

2011-01-22 Thread Zeynel
Hello,

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!

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



Re: [google-appengine] How to use the same variable in two handlers?

2011-01-22 Thread djidjadji
Make merchandise_type a hidden input field of the form generated by
Directory() and get the value in the DirectorySubmitHandler().

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.