pigeon.middleware.conversion.converter¶
Module Contents¶
- class pigeon.middleware.conversion.converter.HTTPRequest(method: str, path: str, headers: dict = None, get: dict = None, data=None, files=None, protocol: str = '1.1', content_type=None, **kwargs)¶
Bases:
pigeon.http.message.HTTPMessage
An HTTP message (obv either response or request)
- property is_error¶
- class pigeon.middleware.conversion.converter.HTTPResponse(headers: dict = None, data: str = None, status: int = 200, cookies=None, protocol: str = '1.1', content_type=None, **kwargs)¶
Bases:
pigeon.http.message.HTTPMessage
An HTTP message (obv either response or request)
- property is_error¶
- class pigeon.middleware.conversion.converter.ParameterDict(data: dict = None)¶
Bases:
collections.UserDict
Similar to a dictionary, but items can also be accessed using <dict>.<key>. If accessed as described above, the dict will return the value or None if no matching item is found.
- keys()¶
D.keys() -> a set-like object providing a view on D’s keys
- items()¶
D.items() -> a set-like object providing a view on D’s items
- values()¶
D.values() -> an object providing a view on D’s values
- class pigeon.middleware.conversion.converter.Manager¶
Used to manage settings and load specified middleware which is only loaded at runtime.
To override settings either the method Manager.override or the Manager.__get_attr__ method is used:
# override settings using a module or similar behaving object my_settings: types.ModuleType = ... Manager.override(my_settings) # override settings one at a time by accessing the attributes (__getattr__) Manager.my_setting = my_value
- classmethod override(new_settings: types.ModuleType | Any)¶
Overrides current settings with new settings provided.
- Parameters:
new_settings – New settings to override old ones with
- pigeon.middleware.conversion.converter.autogenerator(view: Callable) Callable ¶
Wraps a view so that any responses generated from the view will have automatic type conversion.
- pigeon.middleware.conversion.converter.generate(data: Any, mimetype=None) pigeon.http.HTTPResponse ¶
Generates a valid HTTPResponse from returned view data (automatic type conversion). Untyped views may return str or HTTPResponse, typed views may return str, HTTPResponse or any type that can be converted into a valid HTTPResponse by the generator.
- pigeon.middleware.conversion.converter.parse(request: bytes) pigeon.http.HTTPRequest ¶
Parses a bytes representation of an http request and creates a valid HTTPRequest object from it.