guilin 桂林
guilin 桂林

Reputation: 17422

GAE: what are the args of webapp.RequestHanderls get(*args)

I read the document

http://code.google.com/appengine/docs/python/tools/webapp/requesthandlerclass.html

but I cant find any information of the args parameters

Upvotes: 1

Views: 136

Answers (1)

max
max

Reputation: 30063

Depends on the regular expressions in your URL matching. For example:

def main():
    application = webapp.WSGIApplication([
         ('/rechnungsdatencontainer/([a-z0-9_-]+)', RechnungsdatencontainerHandler),
         ('/empfaenger/([A-Za-z0-9_-]+)/rechnungen/([A-Za-z0-9_-]+)\.?(json|pdf|xml|invoic|html)?', RechnungslisteHandler),
         ('/admin/credentials', CredentialsHandler),
         ('/', Homepage)],
        debug=True)
    util.run_wsgi_app(application)

RechnungsdatencontainerHandler.get() sees one parameter, RechnungslisteHandler().get() sees three and CredentialsHandler and Homepage get no parameters.

class RechnungsdatencontainerHandler(webapp.RequestHandler):
    def get(containerid):
        ....

class RechnungslisteHandler(webapp.RequestHandler):
    def get(empfaenger, rechung, fmt):
        ....

Basically every pair of (braces) in the RegExp results in a get parameter.

I assume you could also use named parameters, something like (?P<kundennr>[A-Za-z0-9_-]+) to get kwargs in your get function, but I haven't tried that.

Upvotes: 6

Related Questions