<s> """<STR_LIT>""" <EOL> from collections import namedtuple <EOL> from uuid import uuid4 <EOL> from django . http import HttpResponse <EOL> from django . contrib . gis . db . models . query import GeoQuerySet <EOL> from django . contrib . gis . db . models import GeometryField <EOL> from django import forms as f <EOL> import json <EOL> from django . shortcuts import render_to_response <EOL> from ga_ows . views import common <EOL> from ga_ows . utils import MultipleValueField , BBoxField , CaseInsensitiveDict <EOL> from lxml import etree <EOL> from ga_ows . views . common import RequestForm , CommonParameters , GetCapabilitiesMixin <EOL> from osgeo import ogr <EOL> from django . conf import settings <EOL> from tempfile import gettempdir <EOL> from django . db import connections <EOL> import re <EOL> from lxml import etree <EOL> import os <EOL> class InputParameters ( RequestForm ) : <EOL> """<STR_LIT:U+0020>""" <EOL> srs_name = f . CharField ( ) <EOL> input_format = f . CharField ( ) <EOL> srs_format = f . CharField ( required = False ) <EOL> @ classmethod <EOL> def from_request ( cls , request ) : <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> class PresentationParameters ( RequestForm ) : <EOL> count = f . IntegerField ( ) <EOL> start_index = f . IntegerField ( ) <EOL> max_features = f . IntegerField ( ) <EOL> output_format = f . CharField ( ) <EOL> @ classmethod <EOL> def from_request ( cls , request ) : <EOL> request [ '<STR_LIT:count>' ] = int ( request . get ( '<STR_LIT:count>' , '<STR_LIT:1>' ) ) <EOL> request [ '<STR_LIT>' ] = int ( request . get ( '<STR_LIT>' , '<STR_LIT:1>' ) ) <EOL> request [ '<STR_LIT>' ] = int ( request . get ( '<STR_LIT>' , '<STR_LIT:1>' ) ) <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> class AdHocQueryParameters ( RequestForm ) : <EOL> type_names = MultipleValueField ( ) <EOL> aliases = MultipleValueField ( required = False ) <EOL> filter = f . CharField ( required = False ) <EOL> filter_language = f . CharField ( required = False ) <EOL> resource_id = f . CharField ( required = False ) <EOL> bbox = BBoxField ( ) <EOL> sort_by = f . CharField ( required = False ) <EOL> @ classmethod <EOL> def from_request ( cls , request ) : <EOL> request [ '<STR_LIT>' ] = request . getlist ( '<STR_LIT>' ) <EOL> request [ '<STR_LIT>' ] = request . getlist ( '<STR_LIT>' ) <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT>' ) <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT>' ) <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT>' ) <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT>' ) <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT>' ) <EOL> class StoredQueryParameters ( RequestForm ) : <EOL> stored_query_id = f . CharField ( required = False ) <EOL> @ classmethod <EOL> def from_request ( cls , request ) : <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT>' ) <EOL> class GetFeatureByIdParameters ( RequestForm ) : <EOL> feature_id = f . CharField ( ) <EOL> @ classmethod <EOL> def from_request ( cls , request ) : <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT:id>' ) <EOL> class ResolveParameters ( RequestForm ) : <EOL> resolve = f . CharField ( required = False ) <EOL> resolve_depth = f . IntegerField ( ) <EOL> resolve_timeout = f . FloatField ( ) <EOL> @ classmethod <EOL> def from_request ( cls , request ) : <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT>' ) <EOL> request [ '<STR_LIT>' ] = int ( request . get ( '<STR_LIT>' , '<STR_LIT:0>' ) ) <EOL> request [ '<STR_LIT>' ] = float ( request . get ( '<STR_LIT>' , '<STR_LIT:0>' ) ) <EOL> class CannotLockAllFeatures ( common . OWSException ) : <EOL> """<STR_LIT>""" <EOL> class DuplicateStoredQueryIdValue ( common . OWSException ) : <EOL> """<STR_LIT>""" <EOL> class DuplicateStoredQueryParameterName ( common . OWSException ) : <EOL> """<STR_LIT>""" <EOL> class FeaturesNotLocked ( common . OWSException ) : <EOL> """<STR_LIT>""" <EOL> class InvalidLockId ( common . OWSException ) : <EOL> """<STR_LIT>""" <EOL> class InvalidValue ( common . OWSException ) : <EOL> """<STR_LIT>""" <EOL> class LockHasExpired ( common . OWSException ) : <EOL> """<STR_LIT>""" <EOL> class OperationParsingFailed ( common . OWSException ) : <EOL> """<STR_LIT>""" <EOL> class OperationProcessingFailed ( common . OWSException ) : <EOL> """<STR_LIT>""" <EOL> class ResponseCacheExpired ( common . OWSException ) : <EOL> """<STR_LIT>""" <EOL> class OperationNotSupported ( common . OWSException ) : <EOL> """<STR_LIT>""" <EOL> FeatureDescription = namedtuple ( '<STR_LIT>' , ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:name>' , '<STR_LIT:title>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> StoredQueryParameter = namedtuple ( "<STR_LIT>" , ( '<STR_LIT:type>' , '<STR_LIT:name>' , '<STR_LIT:title>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> StoredQueryExpression = namedtuple ( "<STR_LIT>" , ( '<STR_LIT:text>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> StoredQueryDescription = namedtuple ( "<STR_LIT>" , ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT:title>' , '<STR_LIT>' ) ) <EOL> class WFSAdapter ( object ) : <EOL> """<STR_LIT>""" <EOL> def get_feature_descriptions ( self , request , * types ) : <EOL> raise OperationNotSupported . at ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def list_stored_queries ( self , request ) : <EOL> """<STR_LIT>""" <EOL> queries = dict ( [ ( q [ <NUM_LIT:3> : ] , [ ] ) for q in filter ( lambda x : x . startswith ( "<STR_LIT>" ) , <EOL> reduce ( <EOL> list . __add__ , <EOL> [ c . __dict__ . keys ( ) for c in self . __class__ . mro ( ) ] <EOL> ) <EOL> ) ] ) <EOL> return queries <EOL> def get_features ( self , request , parms ) : <EOL> raise OperationNotSupported . at ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> def supports_feature_versioning ( self ) : <EOL> return False <EOL> class GeoDjangoWFSAdapter ( WFSAdapter ) : <EOL> def __init__ ( self , models ) : <EOL> self . models = { } <EOL> self . srids = { } <EOL> self . geometries = { } <EOL> for model in models : <EOL> self . models [ model . _meta . app_label + "<STR_LIT::>" + model . _meta . object_name ] = model <EOL> for field in model . _meta . fields : <EOL> if isinstance ( field , GeometryField ) : <EOL> self . geometries [ model . _meta . app_label + "<STR_LIT::>" + model . _meta . object_name ] = field <EOL> self . srids [ model . _meta . app_label + "<STR_LIT::>" + model . _meta . object_name ] = field . srid <EOL> def list_stored_queries ( self , request ) : <EOL> sq = super ( GeoDjangoWFSAdapter , self ) . list_stored_queries ( request ) <EOL> fts = list ( self . models . keys ( ) ) <EOL> for k in sq . keys ( ) : <EOL> sq [ k ] = StoredQueryDescription ( name = k , feature_types = fts , title = k , parameters = [ ] ) <EOL> return sq <EOL> def get_feature_descriptions ( self , request , * types ) : <EOL> namespace = request . build_absolute_uri ( ) . split ( '<STR_LIT:?>' ) [ <NUM_LIT:0> ] + "<STR_LIT>" <EOL> for model in self . models . values ( ) : <EOL> if model . objects . count ( ) > <NUM_LIT:0> : <EOL> extent = model . objects . extent ( ) <EOL> else : <EOL> extent = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> yield FeatureDescription ( <EOL> ns = namespace , <EOL> ns_name = model . _meta . app_label , <EOL> name = model . _meta . object_name , <EOL> abstract = model . __doc__ , <EOL> title = model . _meta . verbose_name , <EOL> keywords = [ ] , <EOL> srs = self . srids [ model . _meta . app_label + "<STR_LIT::>" + model . _meta . object_name ] , <EOL> bbox = extent , <EOL> schema = namespace <EOL> ) <EOL> def get_features ( self , request , parms ) : <EOL> if parms . cleaned_data [ '<STR_LIT>' ] : <EOL> squid = "<STR_LIT>" + parms . cleaned_data [ '<STR_LIT>' ] <EOL> try : <EOL> return self . __getattribute__ ( squid ) ( request , parms ) <EOL> except AttributeError : <EOL> raise OperationNotSupported . at ( '<STR_LIT>' , '<STR_LIT>' . format ( squid = squid ) ) <EOL> else : <EOL> return self . AdHocQuery ( request , parms ) <EOL> def AdHocQuery ( self , request , parms ) : <EOL> type_names = parms . cleaned_data [ '<STR_LIT>' ] <EOL> flt = parms . cleaned_data [ '<STR_LIT>' ] <EOL> flt_lang = parms . cleaned_data [ '<STR_LIT>' ] <EOL> bbox = parms . cleaned_data [ '<STR_LIT>' ] <EOL> sort_by = parms . cleaned_data [ '<STR_LIT>' ] <EOL> count = parms . cleaned_data [ '<STR_LIT:count>' ] <EOL> if not count : <EOL> count = parms . cleaned_data [ '<STR_LIT>' ] <EOL> start_index = parms . cleaned_data [ '<STR_LIT>' ] <EOL> srs_name = parms . cleaned_data [ '<STR_LIT>' ] <EOL> srs_format = parms . cleaned_data [ '<STR_LIT>' ] <EOL> model = self . models [ type_names [ <NUM_LIT:0> ] ] <EOL> geometry_field = self . geometries [ type_names [ <NUM_LIT:0> ] ] <EOL> query_set = model . objects . all ( ) <EOL> if bbox : <EOL> mnx , mny , mxx , mxy = bbox <EOL> query_set . filter ( ** { geometry_field . name + "<STR_LIT>" : <EOL> "<STR_LIT>" . format ( <EOL> mnx = mnx , <EOL> mny = mny , <EOL> mxx = mxx , <EOL> mxy = mxy ) <EOL> } ) <EOL> if flt : <EOL> flt = json . loads ( flt ) <EOL> query_set = query_set . filter ( ** flt ) <EOL> if sort_by and '<STR_LIT:U+002C>' in sort_by : <EOL> sort_by = sort_by . split ( '<STR_LIT:U+002C>' ) <EOL> query_set = query_set . order_by ( * sort_by ) <EOL> elif sort_by : <EOL> query_set = query_set . order_by ( sort_by ) <EOL> if start_index and count : <EOL> query_set = query_set [ start_index : start_index + count ] <EOL> elif start_index : <EOL> query_set = query_set [ start_index : ] <EOL> elif count : <EOL> query_set = query_set [ : count ] <EOL> if srs_name : <EOL> if ( not srs_format or srs_format == '<STR_LIT>' ) and srs_name != geometry_field . srid : <EOL> if srs_name . lower ( ) . startswith ( '<STR_LIT>' ) : <EOL> srs_name = srs_name [ <NUM_LIT:5> : ] <EOL> query_set . transform ( int ( srs_name ) ) <EOL> return query_set <EOL> def SQ_GetFeatureById ( self , request , parms ) : <EOL> my_parms = GetFeatureByIdParameters . create ( request . REQUEST ) <EOL> typename , pk = my_parms . cleaned_data [ '<STR_LIT>' ] . split ( '<STR_LIT:.>' ) <EOL> return self . models [ typename ] . objects . filter ( pk = int ( pk ) ) <EOL> class WFSBase ( object ) : <EOL> """<STR_LIT>""" <EOL> adapter = None <EOL> class DescribeFeatureTypeMixin ( WFSBase ) : <EOL> """<STR_LIT>""" <EOL> class Parameters ( <EOL> CommonParameters <EOL> ) : <EOL> type_names = MultipleValueField ( ) <EOL> output_format = f . CharField ( ) <EOL> @ classmethod <EOL> def from_request ( cls , request ) : <EOL> request [ '<STR_LIT>' ] = request . getlist ( '<STR_LIT>' ) + request . getlist ( '<STR_LIT>' ) <EOL> request [ '<STR_LIT>' ] = request . get ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> def _parse_xml_DescribeFeatureType ( self , request ) : <EOL> """<STR_LIT>""" <EOL> def add_ns ( it , ns ) : <EOL> x = it . split ( '<STR_LIT::>' ) <EOL> if len ( x ) > <NUM_LIT:1> : <EOL> return ns [ x [ <NUM_LIT:0> ] ] , x [ <NUM_LIT:1> ] <EOL> else : <EOL> return '<STR_LIT>' , x <EOL> root = etree . fromstring ( request ) <EOL> xmlns = root . get ( '<STR_LIT>' ) <EOL> output_format = root . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if xmlns is not None : <EOL> xmlns = "<STR_LIT:{>" + xmlns + "<STR_LIT:}>" <EOL> else : <EOL> xmlns = "<STR_LIT>" <EOL> namespaces = { } <EOL> for name , value in root . attrib . items ( ) : <EOL> if name . startswith ( xmlns ) : <EOL> namespaces [ value ] = name [ len ( xmlns ) : ] <EOL> type_names = root . get ( '<STR_LIT>' ) <EOL> if type_names is not None : <EOL> type_names = [ add_ns ( n , namespaces ) for n in type_names . split ( '<STR_LIT:U+002C>' ) ] <EOL> else : <EOL> type_names = [ ] <EOL> for elt in root : <EOL> if elt . tag . endswith ( "<STR_LIT>" ) : <EOL> namespace , name = elt . text . split ( "<STR_LIT::>" ) <EOL> namespace = namespaces [ namespace ] <EOL> type_names . append ( ( namespace , name ) ) <EOL> if not len ( type_names ) : <EOL> type_names = '<STR_LIT:all>' <EOL> return DescribeFeatureTypeMixin . Parameters . create ( CaseInsensitiveDict ( { "<STR_LIT>" : type_names , "<STR_LIT>" : output_format } ) ) <EOL> def _response_xml_DescribeFeatureType ( self , response ) : <EOL> return render_to_response ( "<STR_LIT>" , { "<STR_LIT>" : list ( response ) } ) <EOL> def _response_json_DescribeFeatureType ( self , response , callback = None ) : <EOL> rsp = [ ] <EOL> for feature_type in response : <EOL> rsp . append ( { <EOL> "<STR_LIT>" : feature_type . schema , <EOL> "<STR_LIT:name>" : feature_type . name , <EOL> "<STR_LIT>" : feature_type . abstract , <EOL> "<STR_LIT:title>" : feature_type . title , <EOL> "<STR_LIT>" : feature_type . ns_name <EOL> } ) <EOL> if callback is not None : <EOL> return HttpResponse ( callback + "<STR_LIT:(>" + json . dumps ( rsp ) + "<STR_LIT:)>" , mimetype = '<STR_LIT>' ) <EOL> else : <EOL> return HttpResponse ( json . dumps ( rsp ) , mimetype = '<STR_LIT:application/json>' ) <EOL> def DescribeFeatureType ( self , request , kwargs ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in kwargs : <EOL> parms = self . _parse_xml_DescribeFeatureType ( kwargs [ '<STR_LIT>' ] ) <EOL> else : <EOL> parms = DescribeFeatureTypeMixin . Parameters . create ( kwargs ) <EOL> response = self . adapter . get_feature_descriptions ( request , * parms . cleaned_data [ '<STR_LIT>' ] ) <EOL> if parms . cleaned_data [ '<STR_LIT>' ] . endswith ( '<STR_LIT>' ) : <EOL> if '<STR_LIT>' in kwargs : <EOL> return self . _response_json_DescribeFeatureType ( response , callback = kwargs [ '<STR_LIT>' ] ) <EOL> elif '<STR_LIT>' in kwargs : <EOL> return self . _response_json_DescribeFeatureType ( response , callback = kwargs [ '<STR_LIT>' ] ) <EOL> else : <EOL> return self . _response_json_DescribeFeatureType ( response ) <EOL> else : <EOL> return self . _response_xml_DescribeFeatureType ( response ) <EOL> class GetFeatureMixin ( WFSBase ) : <EOL> """<STR_LIT>""" <EOL> class Parameters ( <EOL> CommonParameters , <EOL> InputParameters , <EOL> PresentationParameters , <EOL> AdHocQueryParameters , <EOL> StoredQueryParameters <EOL> ) : <EOL> pass <EOL> def _parse_xml_GetFeature ( self , request ) : <EOL> """<STR_LIT:U+0020>""" <EOL> raise OperationNotSupported . at ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> def GetFeature ( self , request , kwargs ) : <EOL> """<STR_LIT:U+0020>""" <EOL> mimetypes = { <EOL> '<STR_LIT>' : '<STR_LIT:application/json>' <EOL> } <EOL> if '<STR_LIT>' in kwargs : <EOL> parms = self . _parse_xml_GetFeature ( kwargs [ '<STR_LIT>' ] ) <EOL> else : <EOL> parms = GetFeatureMixin . Parameters . create ( kwargs ) <EOL> response = self . adapter . get_features ( request , parms ) <EOL> if isinstance ( response , GeoQuerySet ) : <EOL> layer = None <EOL> db_params = settings . DATABASES [ response . db ] <EOL> if db_params [ '<STR_LIT>' ] . endswith ( '<STR_LIT>' ) : <EOL> from psycopg2 . extensions import adapt <EOL> query , parameters = response . query . get_compiler ( response . db ) . as_sql ( ) <EOL> parameters = tuple ( [ adapt ( p ) for p in parameters ] ) <EOL> query = query % parameters <EOL> drv = ogr . GetDriverByName ( "<STR_LIT>" ) <EOL> connection_string = "<STR_LIT>" . format ( db = db_params [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in db_params and db_params [ '<STR_LIT>' ] : <EOL> connection_string += "<STR_LIT>" . format ( host = db_params [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in db_params and db_params [ '<STR_LIT>' ] : <EOL> connection_string += "<STR_LIT>" . format ( port = db_params [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in db_params and db_params [ '<STR_LIT>' ] : <EOL> connection_string += "<STR_LIT>" . format ( user = db_params [ '<STR_LIT>' ] ) <EOL> if '<STR_LIT>' in db_params and db_params [ '<STR_LIT>' ] : <EOL> connection_string += "<STR_LIT>" . format ( password = db_params [ '<STR_LIT>' ] ) <EOL> conn = drv . Open ( connection_string ) <EOL> layer = conn . ExecuteSQL ( query . encode ( '<STR_LIT:ascii>' ) ) <EOL> elif db_params [ '<STR_LIT>' ] . endswith ( '<STR_LIT>' ) : <EOL> from psycopg2 . extensions import adapt <EOL> query , parameters = response . query . get_compiler ( response . db ) . as_sql ( ) <EOL> parameters = tuple ( [ adapt ( p ) for p in parameters ] ) <EOL> query = query % parameters <EOL> drv = ogr . GetDriverByName ( "<STR_LIT>" ) <EOL> conn = drv . Open ( db_params [ '<STR_LIT>' ] ) <EOL> layer = conn . ExecuteSQL ( query ) <EOL> else : <EOL> layer = response . GetLayerByIndex ( <NUM_LIT:0> ) <EOL> drivers = dict ( [ ( ogr . GetDriver ( drv ) . GetName ( ) , ogr . GetDriver ( drv ) ) for drv in range ( ogr . GetDriverCount ( ) ) if ogr . GetDriver ( drv ) . TestCapability ( ogr . ODrCCreateDataSource ) ] ) <EOL> output_format = parms . cleaned_data [ '<STR_LIT>' ] . decode ( '<STR_LIT:ascii>' ) <EOL> if '<STR_LIT>' in output_format or '<STR_LIT>' in output_format : <EOL> tmpname = "<STR_LIT>" . format ( tmpdir = gettempdir ( ) , uuid = uuid4 ( ) , output_format = '<STR_LIT>' , sep = os . path . sep ) <EOL> drv = ogr . GetDriverByName ( "<STR_LIT>" ) <EOL> ds = drv . CreateDataSource ( tmpname ) <EOL> l2 = ds . CopyLayer ( layer , '<STR_LIT>' ) <EOL> l2 . SyncToDisk ( ) <EOL> del ds <EOL> responsef = open ( tmpname ) <EOL> rdata = responsef . read ( ) <EOL> responsef . close ( ) <EOL> os . unlink ( tmpname ) <EOL> return HttpResponse ( rdata , mimetype = output_format ) <EOL> elif output_format in drivers : <EOL> tmpname = "<STR_LIT>" . format ( tmpdir = gettempdir ( ) , uuid = uuid4 ( ) , output_format = output_format , sep = os . path . sep ) <EOL> drv = drivers [ output_format ] <EOL> ds = drv . CreateDataSource ( tmpname ) <EOL> l2 = ds . CopyLayer ( layer , '<STR_LIT>' ) <EOL> l2 . SyncToDisk ( ) <EOL> del ds <EOL> responsef = open ( tmpname ) <EOL> rdata = responsef . read ( ) <EOL> responsef . close ( ) <EOL> os . unlink ( tmpname ) <EOL> return HttpResponse ( rdata , mimetype = mimetypes . get ( output_format , '<STR_LIT>' ) ) <EOL> else : <EOL> raise OperationProcessingFailed . at ( '<STR_LIT>' , '<STR_LIT>' . format ( of = output_format , formats = drivers . keys ( ) ) ) <EOL> class ListStoredQueriesMixin ( WFSBase ) : <EOL> """<STR_LIT>""" <EOL> def ListStoredQueries ( self , request , kwargs ) : <EOL> """<STR_LIT:U+0020>""" <EOL> queries = self . adapter . list_stored_queries ( request ) <EOL> response = etree . Element ( "<STR_LIT>" ) <EOL> for query , description in queries . items ( ) : <EOL> sub = etree . SubElement ( response , "<STR_LIT>" ) <EOL> etree . SubElement ( sub , "<STR_LIT>" ) . text = query <EOL> for feature_type in description . feature_types : <EOL> etree . SubElement ( sub , '<STR_LIT>' ) . text = feature_type <EOL> return HttpResponse ( etree . tostring ( response , pretty_print = True ) , mimetype = '<STR_LIT>' ) <EOL> class DescribeStoredQueriesMixin ( WFSBase ) : <EOL> class Parameters ( CommonParameters ) : <EOL> stored_query_id = MultipleValueField ( ) <EOL> @ classmethod <EOL> def from_request ( cls , request ) : <EOL> request [ '<STR_LIT>' ] = request . getlist ( '<STR_LIT>' ) <EOL> def DescribeStoredQueries ( self , request , kwargs ) : <EOL> parms = DescribeStoredQueriesMixin . Parameters . create ( kwargs ) <EOL> inspected_queries = parms . cleaned_data [ '<STR_LIT>' ] <EOL> response = etree . Element ( '<STR_LIT>' ) <EOL> for query , description in filter ( lambda ( x , y ) : x in inspected_queries , self . adapter . list_stored_queries ( request ) . items ( ) ) : <EOL> desc = etree . SubElement ( response , "<STR_LIT>" ) <EOL> etree . SubElement ( desc , '<STR_LIT>' ) . text = query <EOL> for parameter in description . parameters : <EOL> p = etree . SubElement ( desc , "<STR_LIT>" , attrib = { "<STR_LIT:name>" : parameter . name , "<STR_LIT:type>" : parameter . type } ) <EOL> etree . SubElement ( p , '<STR_LIT>' ) . text = parameter . title <EOL> etree . SubElement ( p , '<STR_LIT>' ) . text = parameter . abstractS <EOL> if parameter . query_expression : <EOL> etree . SubElement ( p , "<STR_LIT>" , attrib = { <EOL> "<STR_LIT>" : parameter . query_expression . private == True , <EOL> "<STR_LIT>" : parameter . query_expression . language , <EOL> "<STR_LIT>" : '<STR_LIT:U+0020>' . join ( parameter . query_expression . return_feature_types ) <EOL> } ) . text = parameter . query_expression . text <EOL> return HttpResponse ( etree . tostring ( response , pretty_print = True ) , mimetype = '<STR_LIT>' ) <EOL> class CreateStoredQuery ( WFSBase ) : <EOL> def CreateStoredQuery ( self , request , kwargs ) : <EOL> raise OperationNotSupported . at ( "<STR_LIT>" ) <EOL> class DropStoredQuery ( WFSBase ) : <EOL> def DropStoredQuery ( self , request , kwargs ) : <EOL> raise OperationNotSupported . at ( "<STR_LIT>" ) <EOL> class TransactionMixin ( WFSBase ) : <EOL> def Transaction ( self , request , kwargs ) : <EOL> """<STR_LIT:U+0020>""" <EOL> raise OperationNotSupported . at ( '<STR_LIT>' ) <EOL> class GetFeatureWithLockMixin ( WFSBase ) : <EOL> def GetFeatureWithLock ( self , request , kwargs ) : <EOL> raise OperationNotSupported . at ( "<STR_LIT>" ) <EOL> class LockFeatureMixin ( WFSBase ) : <EOL> def LockFeature ( self , request , kwargs ) : <EOL> raise OperationNotSupported . at ( '<STR_LIT>' ) <EOL> class GetPropertyValueMixin ( WFSBase ) : <EOL> class Parameters ( StoredQueryParameters , AdHocQueryParameters ) : <EOL> value_reference = f . CharField ( ) <EOL> resolve_path = f . CharField ( required = False ) <EOL> def from_request ( cls , request ) : <EOL> request [ '<STR_LIT>' ] = request [ '<STR_LIT>' ] <EOL> request [ '<STR_LIT>' ] = request [ '<STR_LIT>' ] <EOL> def GetPropertyValue ( self , request , kwargs ) : <EOL> raise OperationNotSupported . at ( '<STR_LIT>' ) <EOL> class WFS ( <EOL> common . OWSView , <EOL> GetCapabilitiesMixin , <EOL> DescribeFeatureTypeMixin , <EOL> DescribeStoredQueriesMixin , <EOL> GetFeatureMixin , <EOL> ListStoredQueriesMixin , <EOL> GetPropertyValueMixin <EOL> ) : <EOL> """<STR_LIT>""" <EOL> adapter = None <EOL> models = None <EOL> title = None <EOL> keywords = [ ] <EOL> fees = None <EOL> access_constraints = None <EOL> provider_name = None <EOL> addr_street = None <EOL> addr_city = None <EOL> addr_admin_area = None <EOL> addr_postcode = None <EOL> addr_country = None <EOL> addr_email = None <EOL> def __init__ ( self , ** kwargs ) : <EOL> common . OWSView . __init__ ( self , ** kwargs ) <EOL> if self . models : <EOL> self . adapter = GeoDjangoWFSAdapter ( self . models ) <EOL> def get_capabilities_response ( self , request , params ) : <EOL> return render_to_response ( '<STR_LIT>' , { <EOL> "<STR_LIT:title>" : self . title , <EOL> "<STR_LIT>" : self . keywords , <EOL> "<STR_LIT>" : self . fees , <EOL> "<STR_LIT>" : self . access_constraints , <EOL> "<STR_LIT>" : request . build_absolute_uri ( ) . split ( '<STR_LIT:?>' ) [ <NUM_LIT:0> ] , <EOL> "<STR_LIT>" : [ ogr . GetDriver ( drv ) . GetName ( ) for drv in range ( ogr . GetDriverCount ( ) ) if ogr . GetDriver ( drv ) . TestCapability ( ogr . ODrCCreateDataSource ) ] , <EOL> "<STR_LIT>" : self . addr_street , <EOL> "<STR_LIT>" : self . addr_city , <EOL> "<STR_LIT>" : self . addr_admin_area , <EOL> "<STR_LIT>" : self . addr_postcode , <EOL> "<STR_LIT>" : self . addr_country , <EOL> "<STR_LIT>" : False , <EOL> "<STR_LIT>" : False , <EOL> '<STR_LIT>' : self . adapter . get_feature_descriptions ( request ) <EOL> } ) <EOL> class WFST ( WFS , TransactionMixin , GetFeatureWithLockMixin , LockFeatureMixin ) : <EOL> """<STR_LIT>""" <EOL> def get_capabilities_response ( self , request , params ) : <EOL> return render_to_response ( '<STR_LIT>' , { <EOL> "<STR_LIT:title>" : self . title , <EOL> "<STR_LIT>" : self . keywords , <EOL> "<STR_LIT>" : self . fees , <EOL> "<STR_LIT>" : self . access_constraints , <EOL> "<STR_LIT>" : request . build_absolute_uri ( ) . split ( '<STR_LIT:?>' ) [ <NUM_LIT:0> ] , <EOL> "<STR_LIT>" : [ ogr . GetDriver ( drv ) . GetName ( ) for drv in range ( ogr . GetDriverCount ( ) ) if ogr . GetDriver ( drv ) . TestCapability ( ogr . ODrCCreateDataSource ) ] , <EOL> "<STR_LIT>" : self . addr_street , <EOL> "<STR_LIT>" : self . addr_city , <EOL> "<STR_LIT>" : self . addr_admin_area , <EOL> "<STR_LIT>" : self . addr_postcode , <EOL> "<STR_LIT>" : self . addr_country , <EOL> "<STR_LIT>" : self . adapter . supports_feature_versioning ( ) , <EOL> "<STR_LIT>" : True , <EOL> '<STR_LIT>' : self . adapter . get_feature_descriptions ( request ) <EOL> } ) </s>
