#NEWLINE# def __init__( self , rtconfig = None , env = None , version = '3.0.0' ) : #NEWLINE# #INDENT# ' Initialize CSW ' #NEWLINE# if ( not env ) : #NEWLINE# #INDENT# self . environ = os . environ #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . environ = env #NEWLINE# #UNINDENT# self . context = config . StaticContext ( ) #NEWLINE# self . sruobj = None #NEWLINE# self . opensearchobj = None #NEWLINE# self . oaipmhobj = None #NEWLINE# self . kvp = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . mode = 'csw' #NEWLINE# self . async = False #NEWLINE# self . soap = False #NEWLINE# self . request = None #NEWLINE# self . exception = False #NEWLINE# self . status = 'OK' #NEWLINE# self . profiles = None #NEWLINE# self . manager = False #NEWLINE# self . outputschemas = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . mimetype = 'application/xml; charset=UTF-8' #NEWLINE# self . encoding = 'UTF-8' #NEWLINE# self . pretty_print = 0 #NEWLINE# self . domainquerytype = 'list' #NEWLINE# self . orm = 'django' #NEWLINE# self . language = { #NEWLINE# #INDENT# '639_code' : 'en' , #NEWLINE# 'text' : 'english' , #NEWLINE# #UNINDENT# } #NEWLINE# self . process_time_start = time ( ) #NEWLINE# self . iface = csw3 . Csw3 ( server_csw = self ) #NEWLINE# self . request_version = version #NEWLINE# if ( self . request_version == '2.0.2' ) : #NEWLINE# #INDENT# self . iface = csw2 . Csw2 ( server_csw = self ) #NEWLINE# self . context . set_model ( 'csw' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if isinstance ( rtconfig , SafeConfigParser ) : #NEWLINE# #INDENT# self . config = rtconfig #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . config = SafeConfigParser ( ) #NEWLINE# if isinstance ( rtconfig , dict ) : #NEWLINE# #INDENT# for ( section , options ) in rtconfig . items ( ) : #NEWLINE# #INDENT# self . config . add_section ( section ) #NEWLINE# for ( k , v ) in options . items ( ) : #NEWLINE# #INDENT# self . config . set ( section , k , v ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# import codecs #NEWLINE# with codecs . open ( rtconfig , encoding = 'utf-8' ) as scp : #NEWLINE# #INDENT# self . config . readfp ( scp ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# self . response = self . iface . exceptionreport ( 'NoApplicableCode' , 'service' , ( 'Error opening configuration %s' % rtconfig ) ) #NEWLINE# return #NEWLINE# #UNINDENT# self . config . set ( 'server' , 'home' , os . path . dirname ( os . path . join ( os . path . dirname ( __file__ ) , '..' ) ) ) #NEWLINE# self . context . pycsw_home = self . config . get ( 'server' , 'home' ) #NEWLINE# self . context . url = self . config . get ( 'server' , 'url' ) #NEWLINE# log . setup_logger ( self . config ) #NEWLINE# LOGGER . debug ( ( 'running configuration %s' % rtconfig ) ) #NEWLINE# LOGGER . debug ( str ( self . environ [ 'QUERY_STRING' ] ) ) #NEWLINE# if ( not self . config . has_option ( 'server' , 'ogc_schemas_base' ) ) : #NEWLINE# #INDENT# self . config . set ( 'server' , 'ogc_schemas_base' , self . context . ogc_schemas_base ) #NEWLINE# #UNINDENT# if self . config . has_option ( 'server' , 'mimetype' ) : #NEWLINE# #INDENT# self . mimetype = self . config . get ( 'server' , 'mimetype' ) . encode ( ) #NEWLINE# #UNINDENT# if self . config . has_option ( 'server' , 'encoding' ) : #NEWLINE# #INDENT# self . encoding = self . config . get ( 'server' , 'encoding' ) #NEWLINE# #UNINDENT# if self . config . has_option ( 'server' , 'domainquerytype' ) : #NEWLINE# #INDENT# self . domainquerytype = self . config . get ( 'server' , 'domainquerytype' ) #NEWLINE# #UNINDENT# if ( self . config . has_option ( 'server' , 'pretty_print' ) and ( self . config . get ( 'server' , 'pretty_print' ) == 'true' ) ) : #NEWLINE# #INDENT# self . pretty_print = 1 #NEWLINE# #UNINDENT# if ( self . config . has_option ( 'server' , 'spatial_ranking' ) and ( self . config . get ( 'server' , 'spatial_ranking' ) == 'true' ) ) : #NEWLINE# #INDENT# util . ranking_enabled = True #NEWLINE# #UNINDENT# if self . config . has_option ( 'server' , 'language' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# LOGGER . info ( 'Setting language' ) #NEWLINE# lang_code = self . config . get ( 'server' , 'language' ) . split ( '-' ) [ 0 ] #NEWLINE# self . language [ '639_code' ] = lang_code #NEWLINE# self . language [ 'text' ] = self . context . languages [ lang_code ] #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# LOGGER . debug ( ( 'Configuration: %s.' % self . config ) ) #NEWLINE# LOGGER . debug ( ( 'Model: %s.' % self . context . model ) ) #NEWLINE# if self . config . has_option ( 'repository' , 'mappings' ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import imp #NEWLINE# module = self . config . get ( 'repository' , 'mappings' ) #NEWLINE# modulename = ( '%s' % os . path . splitext ( module ) [ 0 ] . replace ( os . sep , '.' ) ) #NEWLINE# LOGGER . debug ( ( 'Loading custom repository mappings from %s.' % module ) ) #NEWLINE# mappings = imp . load_source ( modulename , module ) #NEWLINE# self . context . md_core_model = mappings . MD_CORE_MODEL #NEWLINE# self . context . refresh_dc ( mappings . MD_CORE_MODEL ) #NEWLINE# #UNINDENT# except Exception as err : #NEWLINE# #INDENT# self . response = self . iface . exceptionreport ( 'NoApplicableCode' , 'service' , ( 'Could not load repository.mappings %s' % str ( err ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# LOGGER . debug ( 'Loading outputschemas.' ) #NEWLINE# for osch in pycsw . plugins . outputschemas . __all__ : #NEWLINE# #INDENT# output_schema_module = __import__ ( ( 'pycsw.plugins.outputschemas.%s' % osch ) ) #NEWLINE# mod = getattr ( output_schema_module . plugins . outputschemas , osch ) #NEWLINE# self . outputschemas [ mod . NAMESPACE ] = mod #NEWLINE# #UNINDENT# LOGGER . debug ( ( 'Outputschemas loaded: %s.' % self . outputschemas ) ) #NEWLINE# LOGGER . debug ( ( 'Namespaces: %s' % self . context . namespaces ) )