pigeon.middleware.views¶
Module Contents¶
- pigeon.middleware.views.autogenerator(view: Callable) Callable ¶
Wraps a view so that any responses generated from the view will have automatic type conversion.
- class pigeon.middleware.views.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
- class pigeon.middleware.views.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.views.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.views.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.views.View(target: str, func: Callable, mimetype: str, auth: str)¶
- match(path: str) bool ¶
Check for the requested path matching the views target.
- get_dynamic(path: str) pigeon.utils.common.ParameterDict ¶
Returns dict of dynamic url params.
- class pigeon.middleware.views.ViewHandler¶
- register(target, func, mimetype, auth)¶
Add new view to ViewHandler instance.
- get_auth(target, mimetype)¶
Returns the auth required for the view at <target>
- get_func(path: str, mimetype: str) Callable | None ¶
Returns a decorated version (includes dynamic_params and auth) of the view for the requested path.
- get_available_mimetypes(path: str) list[str] ¶
Returns a list of available mimetypes for the requested path.