#NEWLINE# def on_request( self , request ) : #NEWLINE# #INDENT# if ( not self . on_path ( request ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# params = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# form = False #NEWLINE# parsed_url = request . parsed_url #NEWLINE# if ( request . body and ( request . body is not None ) ) : #NEWLINE# #INDENT# ctype = request . headers . iget ( 'content-type' ) #NEWLINE# if ( ( ctype is not None ) and ctype . startswith ( 'application/x-www-form-urlencoded' ) ) : #NEWLINE# #INDENT# form = True #NEWLINE# params = dict ( parse_qsl ( request . body ) ) #NEWLINE# #UNINDENT# #UNINDENT# params . update ( parse_qsl ( parsed_url . query ) ) #NEWLINE# raw_url = urlunparse ( ( parsed_url . scheme , parsed_url . netloc , parsed_url . path , '' , '' , '' ) ) #NEWLINE# oauth_req = Request . from_consumer_and_token ( self . consumer , token = self . token , http_method = request . method , http_url = raw_url , parameters = params , is_form_encoded = form ) #NEWLINE# oauth_req . sign_request ( self . method , self . consumer , self . token ) #NEWLINE# if form : #NEWLINE# #INDENT# request . body = oauth_req . to_postdata ( ) #NEWLINE# request . headers [ 'Content-Length' ] = len ( request . body ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( request . method in ( 'GET' , 'HEAD' ) ) : #NEWLINE# #INDENT# request . original_url = request . url #NEWLINE# request . url = oauth_req . to_url ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# oauth_headers = oauth_req . to_header ( realm = self . realm ) #NEWLINE# request . headers . update ( oauth_headers )