#NEWLINE# def _process_stack( self , request , action , action_args , content_type , body , accept ) : #NEWLINE# #INDENT# 'Implement the processing stack.' #NEWLINE# try : #NEWLINE# #INDENT# ( meth , extensions ) = self . get_method ( request , action , content_type , body ) #NEWLINE# #UNINDENT# except ( AttributeError , TypeError ) : #NEWLINE# #INDENT# return Fault ( webob . exc . HTTPNotFound ( ) ) #NEWLINE# #UNINDENT# except KeyError as ex : #NEWLINE# #INDENT# msg = ( _ ( 'There is no such action: %s' ) % ex . args [ 0 ] ) #NEWLINE# return Fault ( webob . exc . HTTPBadRequest ( explanation = msg ) ) #NEWLINE# #UNINDENT# except exception . MalformedRequestBody : #NEWLINE# #INDENT# msg = _ ( 'Malformed request body' ) #NEWLINE# return Fault ( webob . exc . HTTPBadRequest ( explanation = msg ) ) #NEWLINE# #UNINDENT# if body : #NEWLINE# #INDENT# msg = ( _ ( "Action: '%(action)s', body: %(body)s" ) % { #NEWLINE# #INDENT# 'action' : action , #NEWLINE# 'body' : unicode ( body , 'utf-8' ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# LOG . debug ( logging . mask_password ( msg ) ) #NEWLINE# #UNINDENT# LOG . debug ( _ ( "Calling method '%(meth)s' (Content-type='%(ctype)s', Accept='%(accept)s')" ) , { #NEWLINE# #INDENT# 'meth' : str ( meth ) , #NEWLINE# 'ctype' : content_type , #NEWLINE# 'accept' : accept , #NEWLINE# #UNINDENT# } ) #NEWLINE# try : #NEWLINE# #INDENT# contents = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if self . _should_have_body ( request ) : #NEWLINE# #INDENT# if ( request . content_length == 0 ) : #NEWLINE# #INDENT# contents = { #NEWLINE# #INDENT# 'body' : None , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# contents = self . deserialize ( meth , content_type , body ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except exception . InvalidContentType : #NEWLINE# #INDENT# msg = _ ( 'Unsupported Content-Type' ) #NEWLINE# return Fault ( webob . exc . HTTPBadRequest ( explanation = msg ) ) #NEWLINE# #UNINDENT# except exception . MalformedRequestBody : #NEWLINE# #INDENT# msg = _ ( 'Malformed request body' ) #NEWLINE# return Fault ( webob . exc . HTTPBadRequest ( explanation = msg ) ) #NEWLINE# #UNINDENT# action_args . update ( contents ) #NEWLINE# project_id = action_args . pop ( 'project_id' , None ) #NEWLINE# context = request . environ . get ( 'rack.context' ) #NEWLINE# if ( context and project_id and ( project_id != context . project_id ) ) : #NEWLINE# #INDENT# msg = ( _ ( "Malformed request URL: URL's project_id '%(project_id)s' doesn't match Context's project_id '%(context_project_id)s'" ) % { #NEWLINE# #INDENT# 'project_id' : project_id , #NEWLINE# 'context_project_id' : context . project_id , #NEWLINE# #UNINDENT# } ) #NEWLINE# return Fault ( webob . exc . HTTPBadRequest ( explanation = msg ) ) #NEWLINE# #UNINDENT# ( response , post ) = self . pre_process_extensions ( extensions , request , action_args ) #NEWLINE# if ( not response ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# with ResourceExceptionHandler ( ) : #NEWLINE# #INDENT# action_result = self . dispatch ( meth , request , action_args ) #NEWLINE# #UNINDENT# #UNINDENT# except Fault as ex : #NEWLINE# #INDENT# response = ex #NEWLINE# #UNINDENT# #UNINDENT# if ( not response ) : #NEWLINE# #INDENT# resp_obj = None #NEWLINE# if ( ( type ( action_result ) is dict ) or ( action_result is None ) ) : #NEWLINE# #INDENT# resp_obj = ResponseObject ( action_result ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( action_result , ResponseObject ) : #NEWLINE# #INDENT# resp_obj = action_result #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# response = action_result #NEWLINE# #UNINDENT# #UNINDENT# if resp_obj : #NEWLINE# #INDENT# serializers = getattr ( meth , 'wsgi_serializers' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# resp_obj . _bind_method_serializers ( serializers ) #NEWLINE# if hasattr ( meth , 'wsgi_code' ) : #NEWLINE# #INDENT# resp_obj . _default_code = meth . wsgi_code #NEWLINE# #UNINDENT# resp_obj . preserialize ( accept , self . default_serializers ) #NEWLINE# response = self . post_process_extensions ( post , resp_obj , request , action_args ) #NEWLINE# #UNINDENT# if ( resp_obj and ( not response ) ) : #NEWLINE# #INDENT# response = resp_obj . serialize ( request , accept , self . default_serializers ) #NEWLINE# #UNINDENT# #UNINDENT# if hasattr ( response , 'headers' ) : #NEWLINE# #INDENT# if context : #NEWLINE# #INDENT# response . headers . add ( 'x-compute-request-id' , context . request_id ) #NEWLINE# #UNINDENT# for ( hdr , val ) in response . headers . items ( ) : #NEWLINE# #INDENT# response . headers [ hdr ] = utils . utf8 ( str ( val ) ) #NEWLINE# #UNINDENT# #UNINDENT# return response