Handlers

Basically you do not need this API but if you are curious feel free to check it out.

BaseHandler

class restae.handlers.BaseHandler(*args, **kwargs)[source]

BaseHandler with some intelligence & automation

apply_dispatch()[source]

Does the hole mechanism of dispatch.

Loops over all middlewares before and after the dispatch method call

for middleware in self.middlewares:
    middleware.process_request(self.request)

self.route_args = self.get_route_args()
response = self.do_dispatch()

for middleware in self.middlewares:
    middleware.process_response(self.request, response)
Returns:webob.Response
dispatch()[source]

Function called to make the dispatch job. Calls internally restae.handlers.BaseHandler.apply_dispatch()

Returns:webob.Response
do_dispatch()[source]

Function that does the dispatch job

Returns:webob.Response
get_body()[source]

Tries to parse the request body as JSON

Returns:JSON serialized data as dict instance.
get_route_args()[source]

Parses the route arguments based on the router generated url

Returns:route arguments in a dict instance.

For instance if the view url is r'/resource/(?P<slug>[^/]+)/' and the calling url is GET /resource/my-slug/

The returned dict will be formatted like this

{'slug': 'my-slug'}

Note

Those route arguments are then available in each of the Handler methods in the self.route_args attribute

middlewares[source]

Cached property that load all middlewares

Returns:list of Middleware instances

APIHandler

class restae.handlers.APIHandler(*args, **kwargs)[source]

APIModelListHandler

class restae.handlers.APIModelListHandler(*args, **kwargs)[source]

ModelHandler that perform a generic list operation

list(request, **kwargs)[source]

List operation

Returns:restae.response.JsonResponse

APIModelCreateHandler

class restae.handlers.APIModelCreateHandler(*args, **kwargs)[source]

ModelHandler that perform a generic create operation

create(request, **kwargs)[source]
Returns:restae.response.JsonResponse

APIModelRetrieveHandler

class restae.handlers.APIModelRetrieveHandler(*args, **kwargs)[source]

ModelHandler that perform a generic get operation

retrieve(request, key=None)[source]
Returns:restae.response.JsonResponse

APIModelUpdateHandler

class restae.handlers.APIModelUpdateHandler(*args, **kwargs)[source]

ModelHandler that perform a generic update operation

APIModelPatchHandler

class restae.handlers.APIModelPatchHandler(*args, **kwargs)[source]

ModelHandler that perform a generic patch operation

APIModelDestroyHandler

class restae.handlers.APIModelDestroyHandler(*args, **kwargs)[source]

ModelHandler that perform a generic delete operation

destroy(request, key=None)[source]
Returns:restae.response.JsonResponse

APIModelMixinHandler

class restae.handlers.APIModelMixinHandler(*args, **kwargs)[source]

APIModelHandler

class restae.handlers.APIModelHandler(*args, **kwargs)[source]
do_dispatch()[source]

Dispatches the request.

This will first check if there’s a handler_method defined in the matched route, and if not it’ll use the method correspondent to the request method (get(), post() etc).