gws.base.ows.server.request¶
OWS service request.
Source code: gws.base.ows.server.request
Module Contents¶
- class gws.base.ows.server.request.Object(service: gws.OwsService, req: gws.WebRequester, params: dict, xml_element: gws.XmlElement = None, is_soap=False)¶
OWS service request.
Holds the request parameters and provides methods to read and validate them. The constructor determines the operation and the version; the service handlers fill in the other attributes (CRS, bounds, sizes) as needed.
- bounds: gws.Bounds¶
Requested bounds.
- customNamespacePrefixes: dict¶
Custom namespace prefixes (uri -> prefix) requested with the
NAMESPACESparameter.
- layerCapsList: list[gws.base.ows.server.core.LayerCaps]¶
Caps of all layers available to the user in this service and project.
- operation: gws.OwsOperation¶
Requested operation.
- params: dict¶
Request parameters, with upper-cased names.
- project: gws.Project¶
Project.
- req: gws.WebRequester¶
Web request.
- service: gws.OwsService¶
Service object.
- xmlElement: gws.XmlElement | None¶
Request body for XML POST requests.
- enum_layer_caps()¶
Create the layer caps for the service root layer or the project root layer.
Only layers the user can read and which are enabled for this service are included. Empty groups are skipped. Groups are listed before their children.
- Returns:
A flat list of layer caps.
- find_operation(param: str) gws.OwsOperation | None¶
Find a supported operation by its name.
- Parameters:
param – Operation name, case-insensitive.
- Returns:
The operation, or
Noneif the service does not support it.
- int_param(param_names: str, default: int | None = None) int¶
Return an integer parameter.
- Parameters:
param_names – Comma-separated parameter names to look for.
default – Default value. If
None, the parameter is required.
- Returns:
The parameter value.
- Raises:
error.MissingParameterValue – If the parameter is required and missing.
error.InvalidParameterValue – If the value is not an integer.
- list_param(param_names: str) list[str]¶
Return a comma-separated parameter as a list.
- Parameters:
param_names – Comma-separated parameter names to look for.
- Returns:
The list of values, empty if the parameter is missing.
- load_project(required=False)¶
Load the project and the layer caps.
The project is the one given by the
projectUidparameter or the project the service is configured for. SetsprojectandlayerCapsList. The layer caps are cached per service, project and user roles.- Parameters:
required – Raise an error if there is no project.
- Raises:
gws.NotFoundError – If the project is required and not found, or does not match the service project.
gws.ForbiddenError – If the user cannot access the project.
- requested_bounds(param_names: str) gws.Bounds | None¶
Return the requested bounding box, transformed to
crs.Uses
crsas the default CRS andalwaysXYfor the axis order.- Parameters:
param_names – Comma-separated parameter names to look for.
- Returns:
The bounds, or
Noneif not requested.- Raises:
error.InvalidParameterValue – If the bounding box is invalid.
- requested_crs(param_names: str) gws.Crs | None¶
Return the requested CRS.
- Parameters:
param_names – Comma-separated parameter names to look for.
- Returns:
The CRS, or
Noneif not requested.- Raises:
error.InvalidCRS – If the CRS is unknown or not supported by the service.
- requested_feature_count(param_names: str) int¶
Return the requested feature count, limited by the service maximum.
- Parameters:
param_names – Comma-separated parameter names to look for.
- Returns:
The feature count, or the service default if not requested or not positive.
- Raises:
error.InvalidParameterValue – If the value is not an integer.
- requested_format(param_names: str) str¶
Return the requested format with whitespace removed.
- Parameters:
param_names – Comma-separated parameter names to look for.
- Returns:
The format, or an empty string if not requested.
- requested_operation(param_names: str) gws.OwsOperation¶
Return the requested operation.
- Parameters:
param_names – Comma-separated parameter names to look for.
- Returns:
The operation.
- Raises:
error.OperationNotSupported – If the operation is not supported by the service.
- requested_version(param_names: str) str¶
Negotiate the service version.
- Parameters:
param_names – Comma-separated parameter names to look for.
- Returns:
The first supported version that starts with a requested version, or the first supported version if no version is requested.
- Raises:
error.VersionNegotiationFailed – If none of the requested versions is supported.
- requested_xmlns_replacements()¶
Read custom namespace prefixes from the
NAMESPACESparameter.- Returns:
A dict mapping namespace uris to prefixes.
- require_project()¶
Load the project and the layer caps, the project is required.
- Raises:
gws.NotFoundError – If the project is not found.
gws.ForbiddenError – If the user cannot access the project.
- string_param(param_names: str, values: set[str] | None = None, default: str | None = None) str¶
Return a string parameter.
- Parameters:
param_names – Comma-separated parameter names to look for.
values – Allowed values, in lower case. If given, the value is lower-cased and checked.
default – Default value. If
None, the parameter is required.
- Returns:
The parameter value.
- Raises:
error.MissingParameterValue – If the parameter is required and missing.
error.InvalidParameterValue – If the value is not allowed.
- class gws.base.ows.server.request.TemplateArgs(*args, **kwargs)¶
Bases:
gws.TemplateArgsArguments for service templates.
- featureCollection: gws.base.ows.server.core.FeatureCollection¶
Search result, for feature requests.
- layerCapsList: list[gws.base.ows.server.core.LayerCaps]¶
Layer caps to include in the response.
- metadataCollection: gws.base.ows.server.core.MetadataCollection¶
Search result, for catalog requests.
- operation: gws.OwsOperation¶
Requested operation.
- project: gws.Project¶
Project.
- service: gws.OwsService¶
Service object.
- tileMatrixSets: list[gws.TileMatrixSet]¶
Tile matrix sets (WMTS).
- url_for: Callable¶
Function that converts a URL or path to a canonical URL.