weaver.wps_restapi.patches

Module Contents

class weaver.wps_restapi.patches.NoAutoHeadList[source]

List that does not allow addition of HTTP HEAD method object references unless allowed once.

Initialize self. See help(type(self)) for accurate signature.

allow_once = False[source]
append(__object: Union[str, Tuple[str, Any, Any]]) None[source]

Append object to the end of the list.

class weaver.wps_restapi.patches.ServiceOnlyExplicitGetHead(*_: Any, **__: Any)[source]

Service that disallow the auto-insertion of HTTP HEAD method view when HTTP GET view is defined.

This service overrides the default cornice.Service in order to avoid auto-insertion of HTTP HEAD view. Similarly to pyramid, the view registration assume that HEAD are always wanted when adding GET definitions. Because HEAD view can be added explicitly, the class also detects these cases to let them pass as expected.

Without this patch, all endpoint would otherwise report erroneous HEAD requests in the generated OpenAPI specification once HEAD is removed from cornice_swagger.CorniceSwagger.ignore_methods.

See also

add_view(method: Union[str, Tuple[str]], view: Any, **kwargs: Any) None[source]

Add a view to a method and arguments.

All the Service keyword params except name and path can be overwritten here. Additionally, api() has following keyword params:

Parameters
  • method – The request method. Should be one of ‘GET’, ‘POST’, ‘PUT’, ‘DELETE’, ‘OPTIONS’, ‘TRACE’, or ‘CONNECT’.

  • view – the view to hook to

  • **kwargs

    additional configuration for this view, including permission.

class weaver.wps_restapi.patches.RequestMethodPredicateNoGetHead(val: Union[str, Tuple[str]], config: pyramid.config.Configurator)[source]
weaver.wps_restapi.patches.patch_pyramid_view_no_auto_head_get_method(config: pyramid.config.Configurator) None[source]

Replace predicate handlers automatically adding HTTP HEAD route/view when HTTP GET are defined by ones that doesn’t.