magpie.api.generic

Module Contents

magpie.api.generic.LOGGER[source]
magpie.api.generic.internal_server_error(request) → HTTPException[source]

Overrides default HTTP.

magpie.api.generic.not_found_or_method_not_allowed(request) → HTTPException[source]

Overrides the default HTTPNotFound [404] by appropriate HTTPMethodNotAllowed [405] when applicable.

Not found response can correspond to underlying process operation not finding a required item, or a completely unknown route (path did not match any existing API definition). Method not allowed is more specific to the case where the path matches an existing API route, but the specific request method (GET, POST, etc.) is not allowed on this path.

Without this fix, both situations return [404] regardless.

magpie.api.generic.unauthorized_or_forbidden(request) → HTTPException[source]

Overrides the default HTTPForbidden [403] by appropriate HTTPUnauthorized [401] when applicable.

Unauthorized response is for restricted user access according to credentials and/or authorization headers. Forbidden response is for operation refused by the underlying process operations.

Without this fix, both situations return [403] regardless.

magpie.api.generic.validate_accept_header_tween(handler, registry)[source]

Tween that validates that the specified request Accept header (if any), is a supported one by the application.

Raises:HTTPNotAcceptable – if Accept header was specified and is not supported.
magpie.api.generic.get_request_info(request, default_message='undefined', exception_details=False) → JSON[source]

Obtains additional content details about the request according to available information.