def _rewrite_url(url):
 (scheme, netloc, path, params, query, fragment) = urlparse(url)
 if (scheme != 'http'):
  return url
 if (':' in netloc):
  (host, port) = netloc.rsplit(':', 1)
 else:
  (host, port) = (netloc, str(80))
 path = (path or '/')
 try:
  out = _reverse(host, port, path)
 except urlresolvers.NoReverseMatch as ex:
  LOGGER.error(("Encountered malformed URL '%s' when rewriting proxied page." % (url,)))
  return None
 if query:
  out = ((out + '?') + query)
 return out

def _rewrite_url ( url ) : ( scheme , netloc , path , params , query , fragment ) = urlparse ( url ) if ( scheme != 'http' ) : return url if ( ':' in netloc ) : ( host , port ) = netloc . rsplit ( ':' , 1 ) else : ( host , port ) = ( netloc , str ( 80 ) ) path = ( path or '/' ) try : out = _reverse ( host , port , path ) except urlresolvers . NoReverseMatch as ex : LOGGER . error ( ( "Encountered malformed URL '%s' when rewriting proxied page." % ( url , ) ) ) return None if query : out = ( ( out + '?' ) + query ) return out
used by _rewrite_links .