gisserver.operations.base module

The base protocol to implement an operation.

The request itself is parsed by gisserver.parsers.wfs20, and handled here. It can be seen as the “controller” that handles the actual request type.

All operations extend from an WFSOperation class. This defines the metadata for the GetCapabilities call and possible output formats.

Each WFSOperation can define a parser_class, or let it autodetect.

Base Classes

class gisserver.operations.base.WFSOperation(view: WFSView, ows_request: ows.BaseOwsRequest)

Basic interface to implement an WFS method.

Each operation in this GIS-server extends from this base class. This class also exposes all requires metadata for the GetCapabilities request.

__init__(view: WFSView, ows_request: ows.BaseOwsRequest)
property all_feature_types_by_name: dict[str, FeatureType]

Create a lookup for feature types by name. This can be cached as the WFSOperation is instantiated with each request.

get_parameters() list[Parameter]

Parameters to advertise in the capabilities for this method.

parser_class: type[BaseOwsRequest] = None

Optionally, mention explicitly what the parser class should be used. Otherwise, it’s automatically resolved from the registered types.

process_request(ows_request: BaseOwsRequest)

Default call implementation: render an XML template.

resolve_feature_type(type_name: str, locator: str = 'typeNames') FeatureType

Find the FeatureType defined in the application that corresponds with the XML type name.

validate_request(ows_request: BaseOwsRequest)

Validate the request.

class gisserver.operations.base.OutputFormatMixin

Mixin to support methods that handle different output formats.

get_output_formats() list[OutputFormat]

List all output formats. This is exposed in GetCapabilities, and used for internal rendering.

resolve_output_format(value, locator='outputFormat') OutputFormat

Select the proper OutputFormat object based on the input value

class gisserver.operations.base.XmlTemplateMixin

Mixin to support methods that render using a template.

get_context_data()

Collect all arguments to use for rendering the XML template

process_request(ows_request: BaseOwsRequest)

Process the request by rendering a Django template.

render_xml(context, ows_request: BaseOwsRequest)

Render the response using a template.

xml_content_type = 'text/xml; charset=utf-8'

The content-type to render.

xml_template_name = None

Default template to use for rendering This is resolved as gisserver/service/version/xml_template_name.

Configuration Classes

class gisserver.operations.base.Parameter(name: str, allowed_values: list[str])

The <ows:Parameter> tag to output in GetCapabilities.

__init__(name: str, allowed_values: list[str]) None
allowed_values: list[str]

The values to report in <ows:AllowedValues><ows:Value>.

name: str

The name of the parameter

class gisserver.operations.base.OutputFormat(content_type, *, subtype=None, renderer_class: type[R] | None = None, max_page_size=None, title=None, in_capabilities=True, **extra)

Bases: Generic[R]

Declare an output format for the method.

These formats are used in the get_output_formats() for any WFSOperation that implements OutputFormatMixin. This also connects the output format with a renderer_class.

__init__(content_type, *, subtype=None, renderer_class: type[R] | None = None, max_page_size=None, title=None, in_capabilities=True, **extra)
Parameters:
  • content_type – The MIME-type used in the request to select this type.

  • subtype – Shorter alias for the MIME-type.

  • renderer_class – The class that performs the output rendering.

  • max_page_size – Used to override the max_page_size of the renderer_class.

  • title – A human-friendly name for an HTML overview page.

  • in_capabilities – Whether this format needs to be advertised in GetCapabilities.

  • extra – Any additional key-value pairs for the definition.

property has_infinite_page_size

Return whether the output format can be unpaginated.

property identifier

The identifier to use in templates as OUTPUTFORMAT input value.

matches(value)

Test whether the ‘value’ is matched by this object.

The regex used captures the content-type (ct), subtype (st), charset (cs) and version (v) from the supplied value.

Some possible input values are: - application/gml+xml - application/gml+xml; version=3.2 - csv - text/csv - application/json; subtype=geojson; charset=utf-8 - geojson

property max_page_size

Override the default max page size

renderer_class: type[R] | None = None

The class that performs the output rendering.