A simple configuration dictionary for the WSGIApplication.
Loaded configurations.
Returns a configuration for a given key.
This can be used by objects that define a default configuration. It will update the app configuration with the default values the first time it is requested, and mark the key as loaded.
Parameters: |
|
---|---|
Raises: | Exception, when a required key is not set or is None. |
A WSGI-compliant application.
Allowed request methods.
Class used for the request object.
alias of Request
Class used for the response object.
alias of Response
Class used for the router object.
alias of Router
Class used for the request context object.
alias of RequestContext
Active WSGIApplication instance. See set_globals().
Active Request instance. See set_globals().
Same as app, for webapp compatibility. See set_globals().
A general purpose flag to indicate development mode: if True, uncaught exceptions are raised instead of using HTTPInternalServerError.
A dictionary to register objects used during the app lifetime.
A dictionary mapping HTTP error codes to callables to handle those HTTP exceptions. See handle_exception().
A Router instance with all URIs registered for the application.
Registers the global variables for app and request.
If webbox.utils.local is available the app and request class attributes are assigned to a proxy object that returns them using thread-local, making the application thread-safe. This can also be used in environments that don’t support threading.
If webbox.utils.local is not available app and request will be assigned directly as class attributes. This should only be used in non-threaded environments.
Parameters: |
|
---|
Clears global variables. See set_globals().
Handles a uncaught exception occurred in __call__().
Uncaught exceptions can be handled by error handlers registered in error_handlers. This is a dictionary that maps HTTP status codes to callables that will handle the corresponding error code. If the exception is not an HTTPException, the status code 500 is used.
The error handlers receive (request, response, exception) and can be a callable or a string in dotted notation to be lazily imported.
If no error handler is found, the exception is re-raised.
Based on idea from Flask.
Parameters: |
|
---|---|
Returns: | The returned value from the error handler. |
Runs this WSGI-compliant application in a CGI environment. Uses wsgiref.handlers.CGIHandler().run().
Creates a request and returns a response for this app.
This is a convenience for unit testing purposes. It receives parameters to build a request and calls the application, returning the resulting response:
class HelloHandler(webapp2.RequestHandler):
def get(self):
self.response.write('Hello, world!')
app = webapp2.WSGIapplication([('/', HelloHandler)])
# Test the app, passing parameters to build a request.
response = app.get_response('/')
assert response.status_int == 200
assert response.body == 'Hello, world!'
Parameters: |
|
---|---|
Returns: | A Response object. |