original_docstring: Factory function for olac views with different configurations.
  
      If applications want to disseminate metadata for other resources than languages
      this function can be used to provide a second olac repository.
      
docstring: Factory function for olac views with different configurations.
  If applications want to disseminate metadata for other resources than languages
  this function can be used to provide a second olac repository.
docstring_tokens: Factory function for olac views with different configurations . If applications want to disseminate metadata for other resources than languages this function can be used to provide a second olac repository .
code: def olac_with_cfg(req, cfg):
      """Factory function for olac views with different configurations.
  
      If applications want to disseminate metadata for other resources than languages
      this function can be used to provide a second olac repository.
      """
      res = dict(verb=None, error=None, response_date=timestamp(), params={}, date=date)
      res['cfg'] = cfg
  
      def response(res):
          return Response(
              render('olac.mako', res, request=req).encode('utf8'),
              content_type='text/xml',
              charset=None)
  
      def error(_error):
          if _error:
              res['error'] = (_error, ERRORS[_error])
          return response(res)
  
      args = dict(req.params.items())
      res['params'] = copy.copy(args)
      res['verb'] = args.pop('verb', None)
  
      if res['verb'] not in VERBS:
          return error("badVerb")
  
      if res['verb'] == 'ListSets':
          return error("noSetHierarchy")
  
      if res['verb'] == 'Identify':
          if args:
              return error("badArgument")
          res['earliest'] = res['cfg'].get_earliest_record(req)
  
      if res['verb'] == 'GetRecord':
          if sorted(args.keys()) != ['identifier', 'metadataPrefix']:
              return error("badArgument")
  
          if args['metadataPrefix'] != MD_PREFIX:
              return error("cannotDisseminateFormat")
  
          try:
              res['language'] = res['cfg'].get_record(req, args['identifier'])
          except AssertionError:
              return error("idDoesNotExist")
  
      if res['verb'] in ['ListIdentifiers', 'ListRecords']:
          if (('metadataPrefix' not in args and 'resumptionToken' not in args)
                  or ('from' in args and not TIMESTAMP_PATTERN.match(args['from']))
                  or ('until' in args and not TIMESTAMP_PATTERN.match(args['until']))):
              return error("badArgument")
  
          if [arg for arg in args if arg not in [
                  'from', 'until', 'metadataPrefix', 'set', 'resumptionToken']]:
              return error("badArgument")
  
          if 'set' in args:
              return error("noSetHierarchy")
  
          if 'resumptionToken' in args:
              if len(args) > 1:
                  return error("badArgument")
  
              try:
                  rt = ResumptionToken(url_arg=args['resumptionToken'])
              except AssertionError:
                  return error("badResumptionToken")
          else:
              rt = ResumptionToken(
                  None, 0, args.get('from', None), args.get('until', None))
  
          q = res['cfg'].query_records(req, from_=rt.from_, until=rt.until)
          res['languages'] = q.offset(rt.offset).limit(rt.limit).all()
          if not res['languages']:
              return error('noRecordsMatch')
  
          if len(res['languages']) < rt.limit:
              res['resumptionToken'] = None
          else:
              rt.offset += rt.limit
              res['resumptionToken'] = rt
  
      if res['verb'] == 'ListMetadataFormats':
          if args and 'identifier' not in args:
              return error("badArgument")
  
      return response(res)
code_tokens: def olac_with_cfg ( req , cfg ) : res = dict ( verb = None , error = None , response_date = timestamp ( ) , params = { } , date = date ) res [ 'cfg' ] = cfg def response ( res ) : return Response ( render ( 'olac.mako' , res , request = req ) . encode ( 'utf8' ) , content_type = 'text/xml' , charset = None ) def error ( _error ) : if _error : res [ 'error' ] = ( _error , ERRORS [ _error ] ) return response ( res ) args = dict ( req . params . items ( ) ) res [ 'params' ] = copy . copy ( args ) res [ 'verb' ] = args . pop ( 'verb' , None ) if res [ 'verb' ] not in VERBS : return error ( "badVerb" ) if res [ 'verb' ] == 'ListSets' : return error ( "noSetHierarchy" ) if res [ 'verb' ] == 'Identify' : if args : return error ( "badArgument" ) res [ 'earliest' ] = res [ 'cfg' ] . get_earliest_record ( req ) if res [ 'verb' ] == 'GetRecord' : if sorted ( args . keys ( ) ) != [ 'identifier' , 'metadataPrefix' ] : return error ( "badArgument" ) if args [ 'metadataPrefix' ] != MD_PREFIX : return error ( "cannotDisseminateFormat" ) try : res [ 'language' ] = res [ 'cfg' ] . get_record ( req , args [ 'identifier' ] ) except AssertionError : return error ( "idDoesNotExist" ) if res [ 'verb' ] in [ 'ListIdentifiers' , 'ListRecords' ] : if ( ( 'metadataPrefix' not in args and 'resumptionToken' not in args ) or ( 'from' in args and not TIMESTAMP_PATTERN . match ( args [ 'from' ] ) ) or ( 'until' in args and not TIMESTAMP_PATTERN . match ( args [ 'until' ] ) ) ) : return error ( "badArgument" ) if [ arg for arg in args if arg not in [ 'from' , 'until' , 'metadataPrefix' , 'set' , 'resumptionToken' ] ] : return error ( "badArgument" ) if 'set' in args : return error ( "noSetHierarchy" ) if 'resumptionToken' in args : if len ( args ) > 1 : return error ( "badArgument" ) try : rt = ResumptionToken ( url_arg = args [ 'resumptionToken' ] ) except AssertionError : return error ( "badResumptionToken" ) else : rt = ResumptionToken ( None , 0 , args . get ( 'from' , None ) , args . get ( 'until' , None ) ) q = res [ 'cfg' ] . query_records ( req , from_ = rt . from_ , until = rt . until ) res [ 'languages' ] = q . offset ( rt . offset ) . limit ( rt . limit ) . all ( ) if not res [ 'languages' ] : return error ( 'noRecordsMatch' ) if len ( res [ 'languages' ] ) < rt . limit : res [ 'resumptionToken' ] = None else : rt . offset += rt . limit res [ 'resumptionToken' ] = rt if res [ 'verb' ] == 'ListMetadataFormats' : if args and 'identifier' not in args : return error ( "badArgument" ) return response ( res )
short_docstring: Factory function for olac views with different configurations.
short_docstring_tokens: Factory function for olac views with different configurations .
comment: """Factory function for olac views with different configurations.
  
      If applications want to disseminate metadata for other resources than languages
      this function can be used to provide a second olac repository.
      """