#NEWLINE# def create_execution_object( liveaction , publish = True ) : #NEWLINE# #INDENT# action_db = action_utils . get_action_by_ref ( liveaction . action ) #NEWLINE# runner = RunnerType . get_by_name ( action_db . runner_type [ 'name' ] ) #NEWLINE# attrs = { #NEWLINE# #INDENT# 'action' : vars ( ActionAPI . from_model ( action_db ) ) , #NEWLINE# 'parameters' : liveaction [ 'parameters' ] , #NEWLINE# 'runner' : vars ( RunnerTypeAPI . from_model ( runner ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# attrs . update ( _decompose_liveaction ( liveaction ) ) #NEWLINE# if ( 'rule' in liveaction . context ) : #NEWLINE# #INDENT# rule = reference . get_model_from_ref ( Rule , liveaction . context . get ( 'rule' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# attrs [ 'rule' ] = vars ( RuleAPI . from_model ( rule ) ) #NEWLINE# #UNINDENT# if ( 'trigger_instance' in liveaction . context ) : #NEWLINE# #INDENT# trigger_instance_id = liveaction . context . get ( 'trigger_instance' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# trigger_instance_id = trigger_instance_id . get ( 'id' , None ) #NEWLINE# trigger_instance = TriggerInstance . get_by_id ( trigger_instance_id ) #NEWLINE# trigger = reference . get_model_by_resource_ref ( db_api = Trigger , ref = trigger_instance . trigger ) #NEWLINE# trigger_type = reference . get_model_by_resource_ref ( db_api = TriggerType , ref = trigger . type ) #NEWLINE# trigger_instance = reference . get_model_from_ref ( TriggerInstance , liveaction . context . get ( 'trigger_instance' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# attrs [ 'trigger_instance' ] = vars ( TriggerInstanceAPI . from_model ( trigger_instance ) ) #NEWLINE# attrs [ 'trigger' ] = vars ( TriggerAPI . from_model ( trigger ) ) #NEWLINE# attrs [ 'trigger_type' ] = vars ( TriggerTypeAPI . from_model ( trigger_type ) ) #NEWLINE# #UNINDENT# parent = _get_parent_execution ( liveaction ) #NEWLINE# if parent : #NEWLINE# #INDENT# attrs [ 'parent' ] = str ( trigger_instance_id . id ) #NEWLINE# #UNINDENT# execution = ActionExecutionDB ( ** attrs ) #NEWLINE# execution = ActionExecution . add_or_update ( execution , publish = publish ) #NEWLINE# if parent : #NEWLINE# #INDENT# if ( str ( execution . id ) not in parent . children ) : #NEWLINE# #INDENT# parent . children . append ( str ( execution . id ) ) #NEWLINE# ActionExecution . add_or_update ( parent ) #NEWLINE# #UNINDENT# #UNINDENT# return execution