def parse_request(resource):
 args = request.args
 headers = request.headers
 r = ParsedRequest()
 r.args = args
 settings = config.DOMAIN[resource]
 if settings['allowed_filters']:
  r.where = args.get(config.QUERY_WHERE)
 if settings['projection']:
  r.projection = args.get(config.QUERY_PROJECTION)
 if settings['sorting']:
  r.sort = args.get(config.QUERY_SORT)
 if settings['embedding']:
  r.embedded = args.get(config.QUERY_EMBEDDED)
 if settings['datasource']['aggregation']:
  r.aggregation = args.get(config.QUERY_AGGREGATION)
 r.show_deleted = (config.SHOW_DELETED_PARAM in args)
 max_results_default = (config.PAGINATION_DEFAULT if settings['pagination'] else 0)
 try:
  r.max_results = int(float(args[config.QUERY_MAX_RESULTS]))
  assert (r.max_results > 0)
 except (ValueError, werkzeug.exceptions.BadRequestKeyError, AssertionError):
  r.max_results = max_results_default
 if settings['pagination']:
  if (config.QUERY_PAGE in args):
   try:
    r.page = (abs(int(args.get(config.QUERY_PAGE))) or 1)
   except ValueError:
    pass
  if (r.max_results > config.PAGINATION_LIMIT):
   r.max_results = config.PAGINATION_LIMIT
 def etag_parse(challenge):
  if (challenge in headers):
   etag = headers[challenge]
   if etag.startswith('W/"'):
    etag = etag.lstrip('W/')
   return etag.replace('"', '')
  else:
   return None
 if headers:
  r.if_modified_since = weak_date(headers.get('If-Modified-Since'))
  r.if_none_match = etag_parse('If-None-Match')
  r.if_match = etag_parse('If-Match')
 return r

def parse_request ( resource ) : args = request . args headers = request . headers r = ParsedRequest ( ) r . args = args settings = config . DOMAIN [ resource ] if settings [ 'allowed_filters' ] : r . where = args . get ( config . QUERY_WHERE ) if settings [ 'projection' ] : r . projection = args . get ( config . QUERY_PROJECTION ) if settings [ 'sorting' ] : r . sort = args . get ( config . QUERY_SORT ) if settings [ 'embedding' ] : r . embedded = args . get ( config . QUERY_EMBEDDED ) if settings [ 'datasource' ] [ 'aggregation' ] : r . aggregation = args . get ( config . QUERY_AGGREGATION ) r . show_deleted = ( config . SHOW_DELETED_PARAM in args ) max_results_default = ( config . PAGINATION_DEFAULT if settings [ 'pagination' ] else 0 ) try : r . max_results = int ( float ( args [ config . QUERY_MAX_RESULTS ] ) ) assert ( r . max_results > 0 ) except ( ValueError , werkzeug . exceptions . BadRequestKeyError , AssertionError ) : r . max_results = max_results_default if settings [ 'pagination' ] : if ( config . QUERY_PAGE in args ) : try : r . page = ( abs ( int ( args . get ( config . QUERY_PAGE ) ) ) or 1 ) except ValueError : pass if ( r . max_results > config . PAGINATION_LIMIT ) : r . max_results = config . PAGINATION_LIMIT def etag_parse ( challenge ) : if ( challenge in headers ) : etag = headers [ challenge ] if etag . startswith ( 'W/"' ) : etag = etag . lstrip ( 'W/' ) return etag . replace ( '"' , '' ) else : return None if headers : r . if_modified_since = weak_date ( headers . get ( 'If-Modified-Since' ) ) r . if_none_match = etag_parse ( 'If-None-Match' ) r . if_match = etag_parse ( 'If-Match' ) return r
try and parse request as an http request .