spresso.view package

Submodules

spresso.view.base module

class JsonView(response_class=<class 'spresso.model.web.base.Response'>, **kwargs)[source]

Bases: spresso.view.base.View

Abstract JSON view class.

json()[source]

Provides the actual JSON content. Has to be implemented by inheriting classes

make_response(response)[source]

Wrapper around json_success_response(). Retrieves the JSON data by calling json().

Parameters:response (spresso.model.web.base.Response) – The response.
Returns:The response returned by json_success_response().
class Script(settings)[source]

Bases: spresso.view.base.TemplateBase

Template view class that is used to render a JavaScript used in SPRESSO.

template()[source]

Return the JS template file from the settings.

Returns:The template file path.
class TemplateBase(settings)[source]

Bases: spresso.model.base.SettingsMixin

Abstract template view class. Uses Jinja2 for template rendering, enabling the use of Jinja2 functionality in templates.

render()[source]

The configuration object is mixed in. A template is chosen, loaded and rendered.

Returns:The rendered template.
template()[source]

Abstract template file definition. Has to be implemented by inheriting classes.

Returns:The template file path.
template_context = {}
class TemplateView(response_class=<class 'spresso.model.web.base.Response'>, **kwargs)[source]

Bases: spresso.view.base.View, spresso.view.base.TemplateBase

Abstract template view class that inserts the template in a HTTP response.

make_response(response)[source]

Wrapper around render(). Adds the rendered template to the response object.

Parameters:response (spresso.model.web.base.Response) – The response.
Returns:The response containing the template.
class View(response_class=<class 'spresso.model.web.base.Response'>, **kwargs)[source]

Bases: object

Basic view class.

Parameters:response_class (optional) – The response class, defaults to spresso.model.web.base.Response.
make_response(response)[source]

Basic Interface method. Can be extended by inheriting classes.

Parameters:
Returns:

The response parameter.

process(response)[source]

Wrapper around make_response(). If no valid response is returned a default instance of type response_class is returned.

Parameters:response – The response.
Returns:The verified response of type response_class.
json_error_response(error, response, status_code=400)[source]

Method for returning a JSON error response, based on a spresso.utils.error.SpressoBaseError.

Parameters:
Returns:

The response containing

the error.

Return type:

spresso.model.web.base.Response

json_success_response(data, response)[source]

Method for returning a JSON success response, based on response data.

Parameters:
Returns:

The response containing the data.

Return type:

spresso.model.web.base.Response

Module contents