ramka.views package#

Submodules#

ramka.views.base_view module#

class ramka.views.base_view.BaseView#

Bases: ABC

Base class for all class-based views.

A class-based view is a view that is defined by a class. It defines methods for all supported request methods.

delete(request: Request, response: Response, **kwargs) None#

DELETE HTTP method handler.

It should be overridden in subclasses to enable support for the DELETE HTTP method.

Parameters:
  • request (Request) – The request.

  • response (Response) – The response.

  • kwargs (dict) – The route parameters.

get(request: Request, response: Response, **kwargs) None#

GET HTTP method handler.

It should be overridden in subclasses to enable support for the GET HTTP method.

Parameters:
  • request (Request) – The request.

  • response (Response) – The response.

  • kwargs (dict) – The route parameters.

patch(request: Request, response: Response, **kwargs) None#

PATCH HTTP method handler.

It should be overridden in subclasses to enable support for the PATCH HTTP method.

Parameters:
  • request (Request) – The request.

  • response (Response) – The response.

  • kwargs (dict) – The route parameters.

post(request: Request, response: Response, **kwargs) None#

POST HTTP method handler.

It should be overridden in subclasses to enable support for the POST HTTP method.

Parameters:
  • request (Request) – The request.

  • response (Response) – The response.

  • kwargs (dict) – The route parameters.

put(request: Request, response: Response, **kwargs) None#

PUT HTTP method handler.

It should be overridden in subclasses to enable support for the PUT HTTP method.

Parameters:
  • request (Request) – The request.

  • response (Response) – The response.

  • kwargs (dict) – The route parameters.

ramka.views.errors module#

ramka.views.errors.default_error_handler(_, response, error: Exception)#

The default handler for all unhandled exceptions.

It sends a 500 error page to the client as all unhandles exceptions are considered as server errors. Instead of sending a genetic 500 error page, it sends a JSON response with the error message.

ramka.views.errors.http_404_not_found(_, response)#

The default 404 handler.

It sends a 404 error page to the client.

ramka.views.errors.http_405_method_not_allowed(_, response)#

The default handler for methods that have not been implemented.

Module contents#

class ramka.views.BaseView#

Bases: ABC

Base class for all class-based views.

A class-based view is a view that is defined by a class. It defines methods for all supported request methods.

delete(request: Request, response: Response, **kwargs) None#

DELETE HTTP method handler.

It should be overridden in subclasses to enable support for the DELETE HTTP method.

Parameters:
  • request (Request) – The request.

  • response (Response) – The response.

  • kwargs (dict) – The route parameters.

get(request: Request, response: Response, **kwargs) None#

GET HTTP method handler.

It should be overridden in subclasses to enable support for the GET HTTP method.

Parameters:
  • request (Request) – The request.

  • response (Response) – The response.

  • kwargs (dict) – The route parameters.

patch(request: Request, response: Response, **kwargs) None#

PATCH HTTP method handler.

It should be overridden in subclasses to enable support for the PATCH HTTP method.

Parameters:
  • request (Request) – The request.

  • response (Response) – The response.

  • kwargs (dict) – The route parameters.

post(request: Request, response: Response, **kwargs) None#

POST HTTP method handler.

It should be overridden in subclasses to enable support for the POST HTTP method.

Parameters:
  • request (Request) – The request.

  • response (Response) – The response.

  • kwargs (dict) – The route parameters.

put(request: Request, response: Response, **kwargs) None#

PUT HTTP method handler.

It should be overridden in subclasses to enable support for the PUT HTTP method.

Parameters:
  • request (Request) – The request.

  • response (Response) – The response.

  • kwargs (dict) – The route parameters.

ramka.views.default_error_handler(_, response, error: Exception)#

The default handler for all unhandled exceptions.

It sends a 500 error page to the client as all unhandles exceptions are considered as server errors. Instead of sending a genetic 500 error page, it sends a JSON response with the error message.

ramka.views.http_404_not_found(_, response)#

The default 404 handler.

It sends a 404 error page to the client.

ramka.views.http_405_method_not_allowed(_, response)#

The default handler for methods that have not been implemented.