self.request.get will return parameters either passed in the URL (for
a get method) or as form data (for a post method). Unlike in, say,
PHP, there's no need to use different syntax based on how the
variables are sent.
On Oct 16, 3:59 am, kang <[EMAIL PROTECTED]> wrote:
> I mean Get method...
>
> I have not seen any Get/parameter method in the page..
>
> def post(self):
> greeting = Greeting()
>
> if users.get_current_user():
> greeting.author = users.get_current_user()
>
> greeting.content = self.request.get('content')
>
> it's in the post function...
>
>
>
> On Thu, Oct 16, 2008 at 2:48 PM, djidjadji <[EMAIL PROTECTED]> wrote:
>
> > > You can not get any parameter by using request.get("id").
> > This is not true. Have a look at
> >http://code.google.com/appengine/docs/gettingstarted/usingdatastore.html
>
> > If you want to use part of the URL path as arguments to the handler
> > you use groups in the
> > webapp.WSGIApplication argument.
> > If the URL has parameters (there is a '?' after the URL path) like
> >www.a.com/?a=1&b=2
> > You use self.request.get('a') in the handler to get the value of parameter
> > 'a'
>
> > 2008/10/16 kang <[EMAIL PROTECTED]>:
> > > I am new to Python and GAE. I just give you the way I solved the
> > > GET/parameters problems:-)I think I need to read some example codes~
>
> > > But I don't think your interpretation is correct. It's not a
> > > Request/parameters problem. It's a Get/parameter problem. Usually we can
> > see
> > > url like /book?id=11. We use get method to visit that page to watch a
> > book
> > > whose id is 11. You can not get any parameter by using request.get("id").
>
> > > So I use /book/11 and
> > > application = webapp.WSGIApplication(
> > > [(r'^/book/(?P(
> > > bookid)$d+)$', Book)],
> > > debug=True)
> > > to get the bookid, and give it to Book.Get(self, bookid) function.
>
> > > On Wed, Oct 15, 2008 at 10:49 PM, Alex Vartan <[EMAIL PROTECTED]>
> > wrote:
>
> > >> Ok, that makes sense. I guess that must be the reason why some of the
> > >> example apps (written by bret taylor) use REquestHandler classes that
> > >> subclass a BaseRequestHandler class that includes the original request
> > >> object:
>
> > >> def generate(self, template_name, template_values={}):
> > >> values = {
> > >> 'request': self.request,
> > >> 'user': users.GetCurrentUser(),
> > >> 'login_url':
> > >> users.CreateLoginURL(self.request.uri),
> > >> 'logout_url': users.CreateLogoutUrl('http://' +
> > >> self.request.host +
> > >> '/logout'),
> > >> 'application_name': 'Questioneer'
> > >> }
> > >> values.update(template_values)
> > >> directory = os.path.dirname(__file__)
> > >> path = os.path.join(directory, os.path.join('templates,',
> > >> template_name))
> > >> self.response.out.write(template.render(path, values,
> > >> debug=_DEBUG))
>
> > >> This seems like a helpful idiom so that all of the original request
> > >> variables for a get are available to the django template code for use
> > >> in POST hidden fields.
> > >> Correct interpretation?
>
> > >> On Oct 14, 5:37 pm, kang <[EMAIL PROTECTED]> wrote:
> > >> > or you can write code like:
> > >> > class Stuff:
> > >> > get(self,favorites):
> > >> > do something here.
>
> > >> > application = webapp.WSGIApplication(
>
> > >> > [(r'^/stuff/favorites/(?P(favorites).*)$', Stuff)],
> > >> > debug=True)
>
> > >> > the url is like :
>
> > >> > /stuff/favorites/oatmeal&raisinbran<
> >http://myapp.com/stuff?favorites=oatmeal&raisinbran>
>
> > >> > On Tue, Oct 14, 2008 at 11:49 PM, Alex Vartan <[EMAIL PROTECTED]>
> > >> > wrote:
>
> > >> > > Let's say I redirect a user to the url:
>
> > >> > > myapp.com/stuff?favorites=oatmeal&raisinbran
>
> > >> > > I generate the page with a def get(self) method in the Stuff
> > >> > > RequestHandler class and use self.request.get('favorites').
>
> > >> > > Then there is a form on the same page (/stuff) which processes some
> > >> > > additional input ('morestuff') and supplies me with a few other
> > pieces
> > >> > > of data via post. When I process this using a def post(self) in
> > Stuff,
> > >> > > I use self.request.get('morestuff').
>
> > >> > > But can I also access the original 'favorites' in the post method? I
> > >> > > can't find any documentation about this but perhaps it's because
> > it's
> > >> > > just obvious. I guess the question is does the self.request object
> > get
> > >> > > cleared after get(self) finishes generating the page, or are the
> > >> > > original query params still available to me when I call
> > >> > > self.request.get in the subsequent post method (is the dictionary of
> > >> > > key value pairs in the request object replaced, or augmented by post
> > >> > > data?)
>
> > >> > > Thanks much,
> > >> > > Alex
>
> > >> > --
> > >> > Stay hungry,Stay foolish.
>
> > > --
> > > Stay hungry,Stay foolish.
>
> --
> Stay hungry,Stay foolish.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---