Django HTCPCP-TEA API¶
Below is an extremely terse summary of the API exposed by Django HTCPCP-TEA.
Models¶
-
class
Pot
(*args, **kwargs)¶ A Tea- or Coffee Pot capable of brewing a choice beverage.
-
name
¶ The name of this pot, e.g. “Joe’s Joe Jar” or “Breville (R) BTM800XL”
-
brew_coffee
¶ Whether this pot can brew coffee.
-
supported_teas
¶ The types of tea that this pot can brew. May be empty.
-
supported_additions
¶ The beverage additions that this pot supported. May be empty.
-
fetch_additions
(addition_names)¶ Return the Additions that this pot supports whose names are in the provided sequence.
If this pot does not support an Addition whose name is provided, raise an Addition.DoesNotExist error.
-
is_teapot
¶ Return True if this pot can serve tea, but cannot serve coffee.
-
tea_capable
¶ Return True if this pot can serve tea.
-
-
class
TeaType
(*args, **kwargs)¶ A variety of tea that can be brewed by a pot.
Per the HTCPCP standard, tea may be available as tea bags or tea leaves.
-
name
¶ The name of this tea type.
-
slug
¶ The URL slug identifying this tea type.
-
-
class
Addition
(*args, **kwargs)¶ A beverage addition that may be specified in the Accept-Additions header field of an HTCPCP request.
-
name
¶ The name of this beverage addition as it would appear in the HTCPCP Accept-Additions header field.
-
type
¶ The type of this additions
-
ALCOHOL
= 'ACL'¶
-
MILK
= 'MLK'¶
-
OTHER
= 'OTR'¶
-
SPICE
= 'SPC'¶
-
SUGAR
= 'SUG'¶
-
SWEETENER
= 'SWT'¶
-
SYRUP
= 'SYP'¶
-
is_milk
¶
-
-
class
ForbiddenCombination
(*args, **kwargs)¶ A combination of additions that is “contrary to the sensibilities of a consensus of drinkers”, either for a specific variety of tea or for all beverages.
-
tea
¶ The type of tea that this forbidden combination applies to. If null, this forbidden combination applies to all beverages.
-
additions
¶ The combination of additions that this forbidden combination forbids.
-
forbids_additions
(requested_additions)¶ Return True if the combination of additions that this ForbiddenCombination prohibits is contained in the specified sequence of additions.
-
Decorators¶
-
require_htcpcp
(func)¶ Decorator to make a view only respond to valid HTCPCP requests.
-
safe_condition
(token)¶ Decorator for adding a
Safe
header to a view’s response to indicate client conditions for the safe handling of a device that brews coffee.The decorator will only have effect if the HTCPCP Safe header extension option is enabled.
See RFC 2324 section 2.2.1.1 for further details.
-
safe_require_user_awake
(func)¶ Decorator for adding an “if-user-awake” safe condition to the Safe header field.
See RFC 2324 section 2.2.1.1 for further details.
Settings¶
-
htcpcp_settings
= _HTCPCPTeaSettings('HTCPCP')¶ Proxy to the standard Django settings that provides defaults for some of this app’s settings.
Access to the Django HTCPCP-TEA settings should be done through this instance.
-
class
_HTCPCPTeaSettings
(settings_prefix)¶ Proxy to the standard Django settings that provides defaults for some of this app’s settings.
-
ALLOW_DEPRECATED_POST
= True¶
-
CHECK_FORBIDDEN
= True¶
-
DISABLE_CSRF
= True¶
-
GET_ADDITIONS
= True¶
-
OVERRIDE_ROOT_URI
= False¶
-
OVERRIDE_SERVER_NAME
= True¶
-
POT_SESSIONS
= True¶
-
RESPONSE_CONTENT_TYPE
= None¶
-
STRICT_MIME_TYPE
= True¶
-
STRICT_REQUEST_BODY
= False¶
-
USE_SAFE_HEADER_EXT
= True¶
-
Utils¶
-
build_alternates
(index_pot=None)¶ Generate the Alternates pairs for available beverages, optionally for a specific pot.
-
find_forbidden_combinations
(requested_additions, tea_slug=None)¶ Return the list of ForbiddenCombinations that prohibit some part of the requested additions.
-
render_alternates_header
(alternates_pairs)¶ Render (uri, content-type) pairs into an RFC 2295 Alternates header value.
-
resolve_requested_additions
(request)¶ Return the requested additions for the provided request.
Additions may be requested in the
Accept-Additions
header field, or (if theHTCPCP_GET_ADDITIONS
settings is enabled) in the query string of a uri.Note that the returned additions are not guaranteed to be valid additions that are supported by any pot.