#NEWLINE# def request( self , kvp ) : #NEWLINE# #INDENT# 'process OAI-PMH request' #NEWLINE# kvpout = { #NEWLINE# #INDENT# 'service' : 'CSW' , #NEWLINE# 'version' : '2.0.2' , #NEWLINE# 'mode' : 'oaipmh' , #NEWLINE# #UNINDENT# } #NEWLINE# LOGGER . debug ( ( 'Incoming kvp: %s' % kvp ) ) #NEWLINE# if ( 'verb' in kvp ) : #NEWLINE# #INDENT# if ( 'metadataprefix' in kvp ) : #NEWLINE# #INDENT# self . metadata_prefix = kvp [ 'metadataprefix' ] #NEWLINE# try : #NEWLINE# #INDENT# kvpout [ 'outputschema' ] = self . _get_metadata_prefix ( kvp [ 'metadataprefix' ] ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# kvpout [ 'outputschema' ] = kvp [ 'metadataprefix' ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . metadata_prefix = 'csw-record' #NEWLINE# #UNINDENT# LOGGER . info ( ( 'metadataPrefix: %s' % self . metadata_prefix ) ) #NEWLINE# if ( kvp [ 'verb' ] in [ 'ListRecords' , 'ListIdentifiers' , 'GetRecord' ] ) : #NEWLINE# #INDENT# kvpout [ 'request' ] = 'GetRecords' #NEWLINE# kvpout [ 'resulttype' ] = 'results' #NEWLINE# kvpout [ 'typenames' ] = 'csw:Record' #NEWLINE# kvpout [ 'elementsetname' ] = 'full' #NEWLINE# #UNINDENT# if ( kvp [ 'verb' ] in [ 'Identify' , 'ListMetadataFormats' , 'ListSets' ] ) : #NEWLINE# #INDENT# kvpout [ 'request' ] = 'GetCapabilities' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( kvp [ 'verb' ] == 'GetRecord' ) : #NEWLINE# #INDENT# kvpout [ 'request' ] = 'GetRecordById' #NEWLINE# if ( 'identifier' in kvp ) : #NEWLINE# #INDENT# kvpout [ 'id' ] = kvp [ 'identifier' ] #NEWLINE# #UNINDENT# if ( ( 'outputschema' in kvpout ) and ( kvp [ 'metadataprefix' ] == 'oai_dc' ) ) : #NEWLINE# #INDENT# del kvpout [ 'outputschema' ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( kvp [ 'verb' ] in [ 'ListRecords' , 'ListIdentifiers' ] ) : #NEWLINE# #INDENT# if ( 'resumptiontoken' in kvp ) : #NEWLINE# #INDENT# kvpout [ 'startposition' ] = kvp [ 'resumptiontoken' ] #NEWLINE# #UNINDENT# if ( ( 'outputschema' in kvpout ) and ( kvp [ 'verb' ] == 'ListIdentifiers' ) ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# if ( ( 'outputschema' in kvpout ) and ( kvp [ 'metadataprefix' ] in [ 'dc' , 'oai_dc' ] ) ) : #NEWLINE# #INDENT# del kvpout [ 'outputschema' ] #NEWLINE# #UNINDENT# start = end = None #NEWLINE# LOGGER . info ( 'Scanning temporal parameters' ) #NEWLINE# if ( 'from' in kvp ) : #NEWLINE# #INDENT# start = ( 'dc:date >= %s' % kvp [ 'from' ] ) #NEWLINE# #UNINDENT# if ( 'until' in kvp ) : #NEWLINE# #INDENT# end = ( 'dc:date <= %s' % kvp [ 'until' ] ) #NEWLINE# #UNINDENT# if any ( [ ( start is not None ) , ( end is not None ) ] ) : #NEWLINE# #INDENT# if all ( [ ( kvp is not None ) , ( end is not None ) ] ) : #NEWLINE# #INDENT# time_query = ( '%s and %s' % ( start , end ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( end is None ) : #NEWLINE# #INDENT# time_query = start #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( start is None ) : #NEWLINE# #INDENT# time_query = end #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# kvpout [ 'constraintlanguage' ] = 'CQL_TEXT' #NEWLINE# kvpout [ 'constraint' ] = time_query #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# LOGGER . debug ( ( 'Resulting parameters: %s' % kvpout ) ) #NEWLINE# return kvpout