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
-
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 isGET /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
-
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
-