#NEWLINE# def _spatial_attribute( self , att , settings , field_name = None , model_att = None ) : #NEWLINE# #INDENT# '\n        DRY routine for calling a spatial stored procedure on a geometry column\n        and attaching its output as an attribute of the model.\n\n        Arguments:\n         att:\n          The name of the spatial attribute that holds the spatial\n          SQL function to call.\n\n         settings:\n          Dictionary of internal settings to customize for the spatial procedure.\n\n        Public Keyword Arguments:\n\n         field_name:\n          The name of the geographic field to call the spatial\n          function on.  May also be a lookup to a geometry field\n          as part of a foreign key relation.\n\n         model_att:\n          The name of the model attribute to attach the output of\n          the spatial function to.\n        ' #NEWLINE# warnings . warn ( ( 'The %s GeoQuerySet method is deprecated. See GeoDjango Functions documentation to find the expression-based replacement.' % att ) , RemovedInDjango20Warning , stacklevel = 2 ) #NEWLINE# settings . setdefault ( 'desc' , None ) #NEWLINE# settings . setdefault ( 'geom_args' , ( ) ) #NEWLINE# settings . setdefault ( 'geom_field' , None ) #NEWLINE# settings . setdefault ( 'procedure_args' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# settings . setdefault ( 'procedure_fmt' , '%(geo_col)s' ) #NEWLINE# settings . setdefault ( 'select_params' , [ ] ) #NEWLINE# connection = connections [ self . db ] #NEWLINE# if settings . get ( 'setup' , True ) : #NEWLINE# #INDENT# ( default_args , geo_field ) = self . _spatial_setup ( att , desc = settings [ 'desc' ] , field_name = field_name , geo_field_type = settings . get ( 'geo_field_type' ) ) #NEWLINE# for ( k , v ) in six . iteritems ( default_args ) : #NEWLINE# #INDENT# settings [ 'procedure_args' ] . setdefault ( k , v ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# geo_field = settings [ 'geo_field' ] #NEWLINE# #UNINDENT# if ( not isinstance ( model_att , six . string_types ) ) : #NEWLINE# #INDENT# model_att = att #NEWLINE# #UNINDENT# for name in settings [ 'geom_args' ] : #NEWLINE# #INDENT# geom = geo_field . get_prep_value ( settings [ 'procedure_args' ] [ name ] ) #NEWLINE# params = geo_field . get_db_prep_lookup ( 'contains' , geom , connection = connection ) #NEWLINE# geom_placeholder = geo_field . get_placeholder ( geom , None , connection ) #NEWLINE# old_fmt = ( '%%(%s)s' % name ) #NEWLINE# new_fmt = ( geom_placeholder % '%%s' ) #NEWLINE# settings [ 'procedure_fmt' ] = settings [ 'procedure_fmt' ] . replace ( old_fmt , new_fmt ) #NEWLINE# settings [ 'select_params' ] . extend ( geom_placeholder ) #NEWLINE# #UNINDENT# fmt = ( '%%(function)s(%s)' % settings [ 'procedure_fmt' ] ) #NEWLINE# if settings . get ( 'select_field' ) : #NEWLINE# #INDENT# select_field = settings [ 'select_field' ] #NEWLINE# if connection . ops . oracle : #NEWLINE# #INDENT# select_field . empty_strings_allowed = False #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# select_field = Field ( ) #NEWLINE# #UNINDENT# self . query . add_annotation ( RawSQL ( ( fmt % settings [ 'procedure_args' ] ) , settings [ 'select_params' ] , select_field ) , model_att ) #NEWLINE# return self