![]() |
App Engine Python SDK
v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
|
Public Member Functions | |
def | initialize |
def | get |
def | post |
def | head |
def | options |
def | put |
def | delete |
def | trace |
def | error |
def | redirect |
def | handle_exception |
def | new_factory |
def | get_url |
Public Attributes | |
request | |
response | |
Our base HTTP request handler. Clients should subclass this class. Subclasses should override get(), post(), head(), options(), etc to handle different HTTP methods.
def google.appengine.ext.webapp._webapp25.RequestHandler.delete | ( | self, | |
args | |||
) |
Handler method for DELETE requests.
def google.appengine.ext.webapp._webapp25.RequestHandler.error | ( | self, | |
code | |||
) |
Clears the response output stream and sets the given HTTP error code. Args: code: the HTTP status error code (e.g., 501)
def google.appengine.ext.webapp._webapp25.RequestHandler.get | ( | self, | |
args | |||
) |
Handler method for GET requests.
def google.appengine.ext.webapp._webapp25.RequestHandler.get_url | ( | cls, | |
args, | |||
kargs | |||
) |
Returns the url for the given handler. The default implementation uses the patterns passed to the active WSGIApplication to create a url. However, it is different from Django's urlresolvers.reverse() in the following ways: - It does not try to resolve handlers via module loading - It does not support named arguments - It performs some post-prosessing on the url to remove some regex operators. - It will try to fill in the left-most missing arguments with the args used in the active request. Args: args: Parameters for the url pattern's groups. kwargs: Optionally contains 'implicit_args' that can either be a boolean or a tuple. When it is True, it will use the arguments to the active request as implicit arguments. When it is False (default), it will not use any implicit arguments. When it is a tuple, it will use the tuple as the implicit arguments. the left-most args if some are missing from args. Returns: The url for this handler/args combination. Raises: NoUrlFoundError: No url pattern for this handler has the same number of args that were passed in.
def google.appengine.ext.webapp._webapp25.RequestHandler.handle_exception | ( | self, | |
exception, | |||
debug_mode | |||
) |
Called if this handler throws an exception during execution. The default behavior is to call self.error(500) and print a stack trace if debug_mode is True. Args: exception: the exception that was thrown debug_mode: True if the web application is running in debug mode
def google.appengine.ext.webapp._webapp25.RequestHandler.head | ( | self, | |
args | |||
) |
Handler method for HEAD requests.
def google.appengine.ext.webapp._webapp25.RequestHandler.initialize | ( | self, | |
request, | |||
response | |||
) |
Initializes this request handler with the given Request and Response.
def google.appengine.ext.webapp._webapp25.RequestHandler.new_factory | ( | cls, | |
args, | |||
kwargs | |||
) |
Create new request handler factory. Use factory method to create reusable request handlers that just require a few configuration parameters to construct. Also useful for injecting shared state between multiple request handler instances without relying on global variables. For example, to create a set of post handlers that will do simple text transformations you can write: class ChangeTextHandler(webapp.RequestHandler): def __init__(self, transform): self.transform = transform def post(self): response_text = self.transform( self.request.request.body_file.getvalue()) self.response.out.write(response_text) application = webapp.WSGIApplication( [('/to_lower', ChangeTextHandler.new_factory(str.lower)), ('/to_upper', ChangeTextHandler.new_factory(str.upper)), ], debug=True) Text POSTed to /to_lower will be lower cased. Text POSTed to /to_upper will be upper cased.
def google.appengine.ext.webapp._webapp25.RequestHandler.options | ( | self, | |
args | |||
) |
Handler method for OPTIONS requests.
def google.appengine.ext.webapp._webapp25.RequestHandler.post | ( | self, | |
args | |||
) |
Handler method for POST requests.
def google.appengine.ext.webapp._webapp25.RequestHandler.put | ( | self, | |
args | |||
) |
Handler method for PUT requests.
def google.appengine.ext.webapp._webapp25.RequestHandler.redirect | ( | self, | |
uri, | |||
permanent = False |
|||
) |
Issues an HTTP redirect to the given relative URL. Args: uri: a relative or absolute URI (e.g., '../flowers.html') permanent: if true, we use a 301 redirect instead of a 302 redirect
def google.appengine.ext.webapp._webapp25.RequestHandler.trace | ( | self, | |
args | |||
) |
Handler method for TRACE requests.