def cleanup_oauth_url(redirect_uri):
 if ('?' in redirect_uri):
  (redirect_base, redirect_query) = redirect_uri.split('?', 1)
  query_dict_items = QueryDict(redirect_query).items()
 else:
  query_dict_items = QueryDict('', True)
 excluded_query_items = [(k, v) for (k, v) in query_dict_items if (k.lower() in DROP_QUERY_PARAMS)]
 for (k, v) in excluded_query_items:
  redirect_uri = remove_query_param(redirect_uri, k)
 redirect_uri = redirect_uri.strip('?')
 redirect_uri = redirect_uri.strip('&')
 return redirect_uri

def cleanup_oauth_url ( redirect_uri ) : if ( '?' in redirect_uri ) : ( redirect_base , redirect_query ) = redirect_uri . split ( '?' , 1 ) query_dict_items = QueryDict ( redirect_query ) . items ( ) else : query_dict_items = QueryDict ( '' , True ) excluded_query_items = [ ( k , v ) for ( k , v ) in query_dict_items if ( k . lower ( ) in DROP_QUERY_PARAMS ) ] for ( k , v ) in excluded_query_items : redirect_uri = remove_query_param ( redirect_uri , k ) redirect_uri = redirect_uri . strip ( '?' ) redirect_uri = redirect_uri . strip ( '&' ) return redirect_uri
we have to maintain order with respect to the queryparams which is a bit of a pain todo: very hacky will subclass querydict to sortedquerydict at some point and use a decent sort function .