duck.contrib.responses.simple_response

This module provides a shortcut to create a simple response with a given response class and icon link.

Module Contents

Functions

_make_simple_response

Transforms a basic response like HttpServerErrorResponse into a nicer simple response.

_simple_response

Transforms a basic response like HttpServerErrorResponse into a nicer simple response.

Data

FAVICON

API

duck.contrib.responses.simple_response.FAVICON

None

exception duck.contrib.responses.simple_response.SimpleResponseError

Bases: Exception

Simple response related errors.

Initialization

Initialize self. See help(type(self)) for accurate signature.

duck.contrib.responses.simple_response._make_simple_response(response_class: Type[duck.http.response.HttpResponse], title: str = None, heading: str = None, body: str = None, icon_link: str = None, icon_type='image/png') duck.http.response.HttpResponse

Transforms a basic response like HttpServerErrorResponse into a nicer simple response.

Parameters:
  • response_class – The response class to be transformed.

  • title – The title of the response, If not provided, response.status_message is used (optional).

  • heading – The heading of the response. If not provided, response.status_message is used (optional).

  • body – The body of the response. If not provided, response.status_explanation is used (optional).

  • icon_link – The link to the icon (optional).

  • icon_type – The type of the icon (optional).

Raises:
Returns:

The transformed response.

Return type:

HttpResponse

duck.contrib.responses.simple_response._simple_response(response_class: Type[duck.http.response.HttpResponse], title: str = None, heading: str = None, body: str = None, icon_link=FAVICON, icon_type='image/png') duck.http.response.HttpResponse

Transforms a basic response like HttpServerErrorResponse into a nicer simple response.

Parameters:
  • response_class – The response class to be transformed.

  • title – The title of the response, If not provided, response.status_message is used (optional).

  • heading – The heading of the response. If not provided, response.status_message is used (optional).

  • body – The body of the response. If not provided, response.status_explanation is used (optional).

  • icon_link – The link to the icon (optional).

  • icon_type – The type of the icon (optional).

Raises:
Returns:

The transformed response.

Return type:

HttpResponse