def get_trace_component_for_action_execution(action_execution_db, liveaction_db):
 if (not action_execution_db):
  raise ValueError('action_execution_db expected.')
 trace_component = {'id': str(action_execution_db.id), 'ref': str(action_execution_db.action.get('ref', ''))}
 caused_by = {}
 parent_context = executions.get_parent_context(liveaction_db=liveaction_db)
 if (liveaction_db and parent_context):
  caused_by['type'] = 'action_execution'
  caused_by['id'] = liveaction_db.context['parent'].get('execution_id', None)
 elif (action_execution_db.rule and action_execution_db.trigger_instance):
  caused_by['type'] = 'rule'
  caused_by['id'] = ('%s:%s' % (action_execution_db.rule['id'], action_execution_db.trigger_instance['id']))
 trace_component['caused_by'] = caused_by
 return trace_component

def get_trace_component_for_action_execution ( action_execution_db , liveaction_db ) : if ( not action_execution_db ) : raise ValueError ( 'action_execution_db expected.' ) trace_component = { 'id' : str ( action_execution_db . id ) , 'ref' : str ( action_execution_db . action . get ( 'ref' , '' ) ) } caused_by = { } parent_context = executions . get_parent_context ( liveaction_db = liveaction_db ) if ( liveaction_db and parent_context ) : caused_by [ 'type' ] = 'action_execution' caused_by [ 'id' ] = liveaction_db . context [ 'parent' ] . get ( 'execution_id' , None ) elif ( action_execution_db . rule and action_execution_db . trigger_instance ) : caused_by [ 'type' ] = 'rule' caused_by [ 'id' ] = ( '%s:%s' % ( action_execution_db . rule [ 'id' ] , action_execution_db . trigger_instance [ 'id' ] ) ) trace_component [ 'caused_by' ] = caused_by return trace_component
returns the trace_component compatible dict representation of an actionexecution .