def CgiDictFromParsedUrl(url):
 environ = {}
 if (url.port is not None):
  environ['SERVER_PORT'] = str(url.port)
 elif (url.scheme == 'https'):
  environ['SERVER_PORT'] = '443'
 elif (url.scheme == 'http'):
  environ['SERVER_PORT'] = '80'
 environ['QUERY_STRING'] = url.query
 environ['SERVER_NAME'] = url.hostname
 if url.path:
  environ['PATH_INFO'] = urlparse.unquote(url.path)
 else:
  environ['PATH_INFO'] = '/'
 return environ

def CgiDictFromParsedUrl ( url ) : environ = { } if ( url . port is not None ) : environ [ 'SERVER_PORT' ] = str ( url . port ) elif ( url . scheme == 'https' ) : environ [ 'SERVER_PORT' ] = '443' elif ( url . scheme == 'http' ) : environ [ 'SERVER_PORT' ] = '80' environ [ 'QUERY_STRING' ] = url . query environ [ 'SERVER_NAME' ] = url . hostname if url . path : environ [ 'PATH_INFO' ] = urlparse . unquote ( url . path ) else : environ [ 'PATH_INFO' ] = '/' return environ
extract cgi variables from a parsed url into a dict .