weaver.tweens ============= .. py:module:: weaver.tweens Module Contents --------------- .. py:data:: LOGGER .. py:data:: OWS_TWEEN_HANDLED :value: 'OWS_TWEEN_HANDLED' .. py:function:: http_validate_response_format_tween_factory(handler: weaver.typedefs.ViewHandler, registry: pyramid.registry.Registry) -> weaver.typedefs.ViewHandler Tween factory that validates that the specified request ``Accept`` header or format queries (if any) is supported. .. note:: This tween limits itself to the validation of :term:`HTML` support according to ``weaver.wps_restapi_html`` configuration. Other endpoint-specific format or Content-Type support are handled and validated as per their corresponding endpoint :mod:`cornice` service definitions, which are also represented in the generated `OpenAPI` specification. :raises HTTPNotAcceptable: if desired ``Accept`` or ``format`` specifier of content-type is not supported. .. py:function:: http_apply_response_format_tween_factory(handler: weaver.typedefs.ViewHandler, registry: pyramid.registry.Registry) -> Callable[[weaver.typedefs.PyramidRequest], weaver.typedefs.AnyViewResponse] Tween factory that applies the request ``Accept`` header according to the requested format for the response. The *requested format* in this case takes into account Web-Browsers automatically applying ``Accept`` with a combination of *visual rendering* headers, notably with ``text/html``. In such case, the format is considered to auto-resolve with the *default* response format of the specific endpoint. .. py:function:: error_repr(http_err: Union[pyramid.httpexceptions.HTTPException, weaver.owsexceptions.OWSException, Exception]) -> str Returns a cleaned up representation string of the HTTP error. Similar and even extended details relative to the HTTP error message are added to facilitate later debugging. .. py:function:: ows_response_tween(request: weaver.typedefs.PyramidRequest, handler: weaver.typedefs.ViewHandler) -> weaver.typedefs.AnyViewResponse Tween that wraps any API request with appropriate dispatch of error conversion to handle formatting. .. py:function:: ows_response_tween_factory_excview(handler: weaver.typedefs.ViewHandler, registry: pyramid.registry.Registry) -> weaver.typedefs.ViewHandler Tween factory which produces a tween which transforms common exceptions into OWS specific exceptions. .. py:function:: ows_response_tween_factory_ingress(handler: weaver.typedefs.ViewHandler, registry: pyramid.registry.Registry) -> weaver.typedefs.ViewHandler Tween factory which produces a tween which transforms common exceptions into OWS specific exceptions. .. py:data:: OWS_RESPONSE_EXCVIEW :value: '' .. py:data:: OWS_RESPONSE_INGRESS :value: '' .. py:data:: HTTP_FORMAT_VALIDATE :value: '' .. py:data:: HTTP_FORMAT_RESPONSE :value: '' .. py:function:: includeme(config: pyramid.config.Configurator) -> None