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.

alwaysXY: bool

Use XY axis order for all CRSs.

bounds: gws.Bounds

Requested bounds.

crs: gws.Crs

Requested CRS.

customNamespacePrefixes: dict

Custom namespace prefixes (uri -> prefix) requested with the NAMESPACES parameter.

isSoap: bool = False

The request was sent as a SOAP envelope.

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.

pxSize: gws.Size

Requested image size in pixels.

req: gws.WebRequester

Web request.

resolution: float

Requested resolution.

resX: float

Requested horizontal resolution.

resY: float

Requested vertical resolution.

service: gws.OwsService

Service object.

targetCrs: gws.Crs

CRS of the output.

version: str

Negotiated service version.

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 None if 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:
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 projectUid parameter or the project the service is configured for. Sets project and layerCapsList. The layer caps are cached per service, project and user roles.

Parameters:

required – Raise an error if there is no project.

Raises:
requested_bounds(param_names: str) → gws.Bounds | None

Return the requested bounding box, transformed to crs.

Uses crs as the default CRS and alwaysXY for the axis order.

Parameters:

param_names – Comma-separated parameter names to look for.

Returns:

The bounds, or None if 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 None if 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 NAMESPACES parameter.

Returns:

A dict mapping namespace uris to prefixes.

require_project()

Load the project and the layer caps, the project is required.

Raises:
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:
class gws.base.ows.server.request.TemplateArgs(*args, **kwargs)

Bases: gws.TemplateArgs

Arguments for service templates.

featureCollection: gws.base.ows.server.core.FeatureCollection

Search result, for feature requests.

gmlVersion: int

GML version for geometries.

intVersion: int

Requested service version as an integer, e.g. 130 for 1.3.0.

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.

request: Object

Service request.

service: gws.OwsService

Service object.

serviceRequest: Object

Service request.

serviceUrl: str

Canonical service URL.

tileMatrixSets: list[gws.TileMatrixSet]

Tile matrix sets (WMTS).

url_for: Callable

Function that converts a URL or path to a canonical URL.

version: str

Requested service version.