Module eoxserver.services.requests

This module defines basic classes for OWS requests and responses to OWS requests.

class eoxserver.services.requests.OWSRequest(http_req, params='', param_type='kvp', decoder=None)

This class is used to encapsulate information about an OWS request.

The constructor expects one required parameter, a Django HttpRequest object http_req.

The params argument shall contain the parameters sent with the request. For GET requests, this can either contain a Django QueryDict object or the query string itself. For POST requests, the argument shall contain the message body as a string.

The param_type argument shall be set to kvp for GET requests and xml for POST requests.

Optionally, a decoder (either a KVPDecoder or XMLDecoder instance initialized with the parameters) can already be conveyed to the request. If it is not present, the appropriate decoder type will be chosen and initialized based on the values of params and param_type.

getHeader(header_name)

Returns the value of the HTTP header header_name, or None if not found.

getParamType()

Returns kvp or xml.

getParamValue(key, default=None)

Returns the value of a parameter named key. The name relates to the schema set for the decoder. You can provide a default value which will be returned if the parameter is not present.

getParamValueStrict(key)

Returns the value of a parameter named key. The name relates to the schema set for the decoder. A DecoderException will be raised if the parameter is not present.

getParams()

Returns the parameters. This method calls the KVPDecoder or XMLDecoder method of the same name. In case of KVP data, this means that a dictionary with the parameter values will be returned instead of the query string, even if the OWSRequest object was initially configured with the query string.

getVersion()

Returns the version for the OGC Web Service. This method is used for version negotiation, in which case the appropriate version cannot simply be read from the request parameters.

setSchema(schema)

Set the decoding schema for the parameter decoder (see eoxserver.core.util.decoders)

setVersion(version)

Sets the version for the OGC Web Service. This method is used for version negotiation, in which case the appropriate version cannot simply be read from the request parameters.

class eoxserver.services.requests.Response(content='', content_type='text/xml', headers={}, status=None)

This class encapsulates the data needed for an HTTP response to an OWS request.

The content argument contains the content of the response message. The content_type argument is set to the MIME type of the response content. The headers argument is expected to be a dictionary of additional HTTP headers to be sent with the response. The status parameter is used to set the HTTP status of the response.