def get_current_url(environ, root_only=False, strip_querystring=False, host_only=False):
 tmp = [environ['wsgi.url_scheme'], '://', get_host(environ)]
 cat = tmp.append
 if host_only:
  return (''.join(tmp) + '/')
 cat(urllib_quote(environ.get('SCRIPT_NAME', '').rstrip('/')))
 if root_only:
  cat('/')
 else:
  cat(urllib_quote(('/' + environ.get('PATH_INFO', '').lstrip('/'))))
  if (not strip_querystring):
   qs = environ.get('QUERY_STRING')
   if qs:
    cat(('?' + qs))
 return ''.join(tmp)

def get_current_url ( environ , root_only = False , strip_querystring = False , host_only = False ) : tmp = [ environ [ 'wsgi.url_scheme' ] , '://' , get_host ( environ ) ] cat = tmp . append if host_only : return ( '' . join ( tmp ) + '/' ) cat ( urllib_quote ( environ . get ( 'SCRIPT_NAME' , '' ) . rstrip ( '/' ) ) ) if root_only : cat ( '/' ) else : cat ( urllib_quote ( ( '/' + environ . get ( 'PATH_INFO' , '' ) . lstrip ( '/' ) ) ) ) if ( not strip_querystring ) : qs = environ . get ( 'QUERY_STRING' ) if qs : cat ( ( '?' + qs ) ) return '' . join ( tmp )
a handy helper function that recreates the full url for the current request or parts of it .