autopush.web.base

class autopush.web.base.ThreadedValidate(schema)[source]

A cyclone request validation decorator

Exposed as a classmethod for running a marshmallow-based validation schema in a separate thread for a cyclone request handler.

_validate_request(request_handler, *args, **kwargs)[source]

Validates a schema_class against a cyclone request

_track_validation_timing(result, request_handler, start_time)[source]

Track the validation timing

classmethod validate(schema)[source]

Validate a request schema in a separate thread before calling the request handler

An alias threaded_validate should be used from this module.

Using cyclone.web.asynchronous is not needed as this function will attach equivilant functionality to the method handler. Calling self.finish() is needed on decorated handlers.

Validated requests are deserialized into the **kwargs of the wrapped request handler method.

class MySchema(Schema):
    uaid = fields.UUID(allow_none=True)

class MyHandler(cyclone.web.RequestHandler):
    @threaded_validate(MySchema())
    def post(self, uaid=None):
        ...
class autopush.web.base.BaseWebHandler(application, request, **kwargs)[source]

Common overrides for Push web API’s

initialize()[source]

Setup basic aliases and attributes

prepare()[source]

Common request preparation

options(*args, **kwargs)[source]

HTTP OPTIONS Handler

head(*args, **kwargs)[source]

HTTP HEAD Handler

_write_response(status_code, errno, message=None, error=None, headers=None, url='http://autopush.readthedocs.io/en/latest/http.html#error-codes', router_type=None, vapid=None)[source]

Writes out a full JSON error and sets the appropriate status

_validation_err(fail)[source]

errBack for validation errors

_response_err(fail)[source]

errBack for all exceptions that should be logged

This traps all exceptions to prevent any further callbacks from running.

_boto_err(fail)[source]

errBack for boto exceptions (ClientError)

_router_fail_err(fail, router_type=None, vapid=False, uaid=None)[source]

errBack for router failures

_write_validation_err(errors)[source]

Writes a set of validation errors out with details about what went wrong

_db_error_handling(d)[source]

Tack on the common error handling for a dynamodb request and uncaught exceptions

_track_timing(status_code=None)[source]

Logs out the request timing tracking stats

Note: The status code should be set before calling this function or passed in.

class autopush.web.base.BaseWebHandler(application, request, **kwargs)[source]

Common overrides for Push web API’s

initialize()[source]

Setup basic aliases and attributes

prepare()[source]

Common request preparation

options(*args, **kwargs)[source]

HTTP OPTIONS Handler

head(*args, **kwargs)[source]

HTTP HEAD Handler

_write_response(status_code, errno, message=None, error=None, headers=None, url='http://autopush.readthedocs.io/en/latest/http.html#error-codes', router_type=None, vapid=None)[source]

Writes out a full JSON error and sets the appropriate status

_validation_err(fail)[source]

errBack for validation errors

_response_err(fail)[source]

errBack for all exceptions that should be logged

This traps all exceptions to prevent any further callbacks from running.

_boto_err(fail)[source]

errBack for boto exceptions (ClientError)

_router_fail_err(fail, router_type=None, vapid=False, uaid=None)[source]

errBack for router failures

_write_validation_err(errors)[source]

Writes a set of validation errors out with details about what went wrong

_db_error_handling(d)[source]

Tack on the common error handling for a dynamodb request and uncaught exceptions

_track_timing(status_code=None)[source]

Logs out the request timing tracking stats

Note: The status code should be set before calling this function or passed in.