Overriding Server Logic¶
There are a few places where the server logic can be overwritten:
There are a few places that allow to customize the WFS logic:
View Layer¶
The following methods of the WFSView can be overwritten:
get_feature_types()to dynamically generate all exposed features.get_service_description()to dynamically generate the description.xml_namespace_aliasescan define aliases for namespaces. (default is{"app": self.xml_namespace}).dispatch()to implement basic auth.check_permissions()to check for permissions
The permission checks can access the self.request.user object in Django, and inspect the fully parsed WFS request in self.request.ows_request.
Feature Layer¶
Overriding FeatureType allows to change how particular features and fields are exposed.
It can also override the internal XML Schema Definition (XSD) that all output and query filters read.
This can also adjust the
Overriding
check_permissions()allows to perform a permission check before the feature can be read (e.g. a login role check).Overriding
get_queryset()allows to define the queryset per request.Overriding
xsd_typeconstructs the internal XSD definition of this feature.Overriding
xsd_type_classdefines which class constructs the XSD.
The field() function returns a FeatureField.
Instances of this class can be passed directly to the FeatureType(fields=...) parameter,
and override these attributes:
xsd_elementconstructs the internal XSD that filters and output formats use.xsd_element_classdefines which class defines the attribute.
XSD Layer¶
The feature fields generate an internal XML Schema Definition (XSD) that defines how
properties are read, and where the underlying ORM field/relation can be found.
These types can be overwritten for custom behavior, and then be returned by
custom FeatureType and FeatureField objects.
XsdComplexTypedefines a complete class with elements and attributes.XsdElementdefines a property that becomes a normal element.XsdAttributedefines the attributes (onlygml:idis currently rendered).
The elements and attributes have the following fields:
orm_path- returns where to find the ORM relation.orm_field- returns the first part of the ORM relation.orm_relation- returns the ORM relation as path and final field name.get_value()- how to read the attribute value.format_raw_value()- format raw-retrieved values from the database (e.g.values()query).to_python()- how to cast input data.validate_comparison()- checks a field supports a certain data type.build_lhs_part()- how to generate the ORM left-hand-side.build_rhs_part()- how to generate the ORM right-hand-side.
Request Parsing¶
The classes in gisserver.parsers.wfs20 translate the XML POST request into an internal
representation of the request. Each class closely mirrors the definitions in the WFS 2.0 specification.
The GET request parsing (KVP format) is a special case of these classes.
New parser classes may be added for operations that are not implemented yet (such as WFS-T or creating stored queries).
Subsequently, a WFSOperation needs to be implemented that handles this request.
That operation needs to be registered in WFSView’s accept_operations attribute.
The WFSOperation may also define a parser_class to
override which parser handles the request.