WSGI Application¶
The code in here is basically a vanilla
webapp2.WSGIApplication class with additional error handling capabilites. See Error Handling Guide for a reference.
Also Route is included for your convenience.
For example in app.yaml add:
handlers:
- url: /
script: home.app
home.py should look like this:
from gaetk2.handlers import DefaultHandler
from gaetk2.application import WSGIApplication, Route
class HomeHandler(DefaultHandler):
def get(self):
self.return_text('it worked')
app = WSGIApplication([Route('/', handler=HomeHandler)])
gaetk2.application package¶
-
class
gaetk2.application.WSGIApplication(routes=None, debug=False, config=None)[source]¶ Overwrite exception handling.
For further information see the paret class at http://webapp2.readthedocs.io/en/latest/api/webapp2.html#webapp2.WSGIApplication
-
handle_exception(request, response, e)[source]¶ 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 anHTTPException, 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.
Parameters: - request – A
Requestinstance. - response – A
Responseinstance. - e – The uncaught exception.
Returns: The returned value from the error handler.
- request – A
-
get_sentry_addon(request)[source]¶ This tries to extract additional data from the request for Sentry after an Exception tootk place.
Parameters: request – The Request Object Returns: a dict to be sent to sentry as addon.
-
classify_exception(request, exception)[source]¶ Based on the exception raised we classify it for logging.
We not only return an HTTP Status code and level, but also a fingerprint and dict of tags to help snetry group the errors.
-
-
class
gaetk2.application.Route(template, handler=None, name=None, defaults=None, build_only=False, handler_method=None, methods=None, schemes=None)[source]¶ A route definition that maps a URI path to a handler.
The initial concept was based on `Another Do-It-Yourself Framework`_, by Ian Bicking.