gisserver.parsers.ows package¶
Generic Open Web Services (OWS) protocol bits to handle incoming requests.
This is the common logic between WFS, WMS and other protocols.
These translate both request-syntax formats in the same internal objects that the rest of the controller/view logic can use.
- class gisserver.parsers.ows.BaseOwsRequest(service: str, version: str | None, handle: str | None)¶
Bases:
AstNodeBase request data for all request types of the OWS standards. This mirrors the
<wfs:BaseRequestType>element from the WFS spec.- classmethod base_kvp_init_parameters(kvp: KVPRequest) dict¶
Parse the common Key-Value-Pair format (GET request parameters). This parses the syntax:
?SERVICE=WFS&VERSION=2.0.0
- classmethod base_xml_init_parameters(element: NSElement) dict¶
Parse the base attributes. This parses the syntax such as:
<wfs:BaseRequest service="WFS" version="2.0.0" handle="...">
- classmethod from_kvp_request(kvp: KVPRequest)¶
Initialize from an KVP GET request.
- class gisserver.parsers.ows.KVPRequest(query_string: dict[str, str], ns_aliases: dict[str, str] | None = None)¶
Bases:
objectThe Key-Value-Pair (KVP) request format.
This handles parameters from the HTTP GET request. It includes notation format support for certain parameters, such as comma-separated lists, and parenthesis-grouping notations.
Some basic validation is performed, allowing to convert the data into Python types.
- get_custom(name: str, *, alias: str | None = None, default=Ellipsis, parser=None)¶
Retrieve a value by name. This performs basic validation, similar to what the XML parsing does.
Any parsing errors or validation checks are raised as WFS Exceptions, meaning the client will get the appropriate response.
- Parameters:
name – The name of the parameter, typically given in its XML notation format (camelCase).
alias – An older WFS 1 to try for compatibility (e.g. TYPENAMES/TYPENAME, COUNT/MAXFEATURES)
default – The default value to return. If not provided, the parameter is required.
parser – A custom Python function or type to convert the value with.
- get_int(name: str, *, alias: str | None = None, default: int | None = Ellipsis) int | None¶
Retrieve an integer value from the request.
- get_list(name, *, alias: str | None = None, default: list | None = Ellipsis) list[str] | None¶
Retrieve a comma-separated list value from the request.
- get_str(name: str, *, alias: str | None = None, default: str | None = Ellipsis) str | None¶
Retrieve a string value from the request.
- split_parameter_lists() list[KVPRequest]¶
Split the parameter lists into individual requests.
This translates a request such as:
TYPENAMES=(ns1:F1,ns2:F2)(ns1:F1,ns1:F1) &ALIASES=(A,B)(C,D) &FILTER=(<Filter>… for A,B …</Filter>)(<Filter>…for C,D…</Filter>)
into separate pairs:
TYPENAMES=ns1:F1,ns2:F2&ALIASES=A,B&FILTER=<Filter>…for A,B…</Filter> TYPENAMES=ns1:F1,ns1:F1&ALIASES=C,D&FILTER=<Filter>…for C,D…</Filter>
It’s both possible have some query parameters split and some shared. For example to have two different bounding boxes:
TYPENAMES=(INWATER_1M)(BuiltUpA_1M)&BBOX=(40.9821,...)(40.5874,...)
or have a single bounding box for both queries:
TYPENAMES=(INWATER_1M)(BuiltUpA_1M)&BBOX=40.9821,23.4948,41.0257,23.5525
- gisserver.parsers.ows.parse_get_request(query_string: str | dict[str, str], ns_aliases: dict | None = None) BaseOwsRequest¶
Parse the WFS KVP GET request format into the internal request objects. Most code calls the resolver internally, but this variation is easier for unit testing.
- gisserver.parsers.ows.parse_post_request(xml_string: str | bytes, ns_aliases: dict | None = None) BaseOwsRequest¶
Parse the XML POST request format into the internal request objects. Most code calls the resolver internally, but this variation is easier for unit testing.
- gisserver.parsers.ows.resolve_kvp_parser_class(kvp: KVPRequest) type[BaseOwsRequest]¶
Find the appropriate class to parse the KVP GET request data.
- gisserver.parsers.ows.resolve_xml_parser_class(root: NSElement) type[BaseOwsRequest]¶
Find the correct class to parse the XML POST data with.