def make_pre_authed_env(env, method=None, path=None, agent='Swift', query_string=None, swift_source=None):
 newenv = {}
 for name in ('eventlet.posthooks', 'HTTP_USER_AGENT', 'HTTP_HOST', 'PATH_INFO', 'QUERY_STRING', 'REMOTE_USER', 'REQUEST_METHOD', 'SCRIPT_NAME', 'SERVER_NAME', 'SERVER_PORT', 'SERVER_PROTOCOL', 'swift.cache', 'swift.source', 'swift.trans_id'):
  if (name in env):
   newenv[name] = env[name]
 if method:
  newenv['REQUEST_METHOD'] = method
 if path:
  newenv['PATH_INFO'] = path
  newenv['SCRIPT_NAME'] = ''
 if (query_string is not None):
  newenv['QUERY_STRING'] = query_string
 if agent:
  newenv['HTTP_USER_AGENT'] = (agent % {'orig': env.get('HTTP_USER_AGENT', '')}).strip()
 elif ((agent == '') and ('HTTP_USER_AGENT' in newenv)):
  del newenv['HTTP_USER_AGENT']
 if swift_source:
  newenv['swift.source'] = swift_source
 newenv['swift.authorize'] = (lambda req: None)
 newenv['swift.authorize_override'] = True
 newenv['REMOTE_USER'] = '.wsgi.pre_authed'
 newenv['wsgi.input'] = StringIO('')
 if ('SCRIPT_NAME' not in newenv):
  newenv['SCRIPT_NAME'] = ''
 return newenv

def make_pre_authed_env ( env , method = None , path = None , agent = 'Swift' , query_string = None , swift_source = None ) : newenv = { } for name in ( 'eventlet.posthooks' , 'HTTP_USER_AGENT' , 'HTTP_HOST' , 'PATH_INFO' , 'QUERY_STRING' , 'REMOTE_USER' , 'REQUEST_METHOD' , 'SCRIPT_NAME' , 'SERVER_NAME' , 'SERVER_PORT' , 'SERVER_PROTOCOL' , 'swift.cache' , 'swift.source' , 'swift.trans_id' ) : if ( name in env ) : newenv [ name ] = env [ name ] if method : newenv [ 'REQUEST_METHOD' ] = method if path : newenv [ 'PATH_INFO' ] = path newenv [ 'SCRIPT_NAME' ] = '' if ( query_string is not None ) : newenv [ 'QUERY_STRING' ] = query_string if agent : newenv [ 'HTTP_USER_AGENT' ] = ( agent % { 'orig' : env . get ( 'HTTP_USER_AGENT' , '' ) } ) . strip ( ) elif ( ( agent == '' ) and ( 'HTTP_USER_AGENT' in newenv ) ) : del newenv [ 'HTTP_USER_AGENT' ] if swift_source : newenv [ 'swift.source' ] = swift_source newenv [ 'swift.authorize' ] = ( lambda req : None ) newenv [ 'swift.authorize_override' ] = True newenv [ 'REMOTE_USER' ] = '.wsgi.pre_authed' newenv [ 'wsgi.input' ] = StringIO ( '' ) if ( 'SCRIPT_NAME' not in newenv ) : newenv [ 'SCRIPT_NAME' ] = '' return newenv
returns a new fresh wsgi environment with escalated privileges to do backend checks .