magpie.utils¶
Module Contents¶
-
magpie.utils.get_logger(name, level=None)[source]¶ Immediately sets the logger level to avoid duplicate log outputs from the root logger and this logger when level is NOTSET.
-
magpie.utils.isclass(obj)[source]¶ Evaluate an object for class type (ie: class definition, not an instance nor any other type).
Parameters: obj – object to evaluate for class type Returns: (bool) indicating if object is a class
-
magpie.utils.get_settings_from_config_ini(config_ini_path, ini_main_section_name='app:magpie_app')[source]¶
-
magpie.utils.get_json(response)[source]¶ Retrieves the ‘JSON’ body of a response using the property/callable according to the response’s implementation.
-
magpie.utils.get_header(header_name, header_container, default=None, split=None) → Optional[Str][source]¶ Retrieves
header_nameby fuzzy match (independently of upper/lower-case and underscore/dash) from various framework implementations ofHeaders.If
splitis specified, the matchedheader_nameis first split with it and the first item is returned. This allows to parse complex headers (e.g.:text/plain; charset=UTF-8totext/plainwithsplit=';').Parameters: - header_name – header to find.
- header_container – where to look for header_name.
- default – value to returned if header_container is invalid or header_name could not be found.
- split – character(s) to use to split the found header_name.
-
magpie.utils.convert_response(response) → Response[source]¶ Converts a
responseimplementation (e.g.:requests.Response) to an equivalentpyramid.response.Responseversion.
-
magpie.utils.patch_magpie_url(container) → SettingsType[source]¶ Updates potentially missing configuration settings for normal application execution.
-
magpie.utils.log_request(event)[source]¶ Subscriber event that logs basic details about the incoming requests.
-
magpie.utils.log_exception_tween(handler, registry)[source]¶ Tween factory that logs any exception before re-raising it.
Application errors are marked as
ERRORwhile non critical HTTP errors are marked asWARNING.