def add_key_to_url(url, scheme, key):
 query = request.args.to_dict()
 query['view_only'] = key
 replacements = {'query': urllib.urlencode(query)}
 if scheme:
  replacements['scheme'] = scheme
 parsed_url = urlparse.urlparse(url)
 if parsed_url.fragment:
  replacements['path'] = '{}%23{}'.format(parsed_url.path, parsed_url.fragment)
  replacements['fragment'] = ''
 parsed_redirect_url = parsed_url._replace(**replacements)
 return urlparse.urlunparse(parsed_redirect_url)

def add_key_to_url ( url , scheme , key ) : query = request . args . to_dict ( ) query [ 'view_only' ] = key replacements = { 'query' : urllib . urlencode ( query ) } if scheme : replacements [ 'scheme' ] = scheme parsed_url = urlparse . urlparse ( url ) if parsed_url . fragment : replacements [ 'path' ] = '{}%23{}' . format ( parsed_url . path , parsed_url . fragment ) replacements [ 'fragment' ] = '' parsed_redirect_url = parsed_url . _replace ( ** replacements ) return urlparse . urlunparse ( parsed_redirect_url )
redirects the user to the requests url with the given key appended to the query parameters .