Use this decorator on Step.action implementation.

    Your action method should always return variables, or
    both variables and output.

    This decorator will update variables with output.
436424
def update_variables(func):
    

    @wraps(func)
    def wrapper(self, *args, **kwargs):
        result = func(self, *args, **kwargs)
        if isinstance(result, tuple):
            return self.process_register(result[0], result[1])
        else:
            return self.process_register(result)

    return wrapper
73123
def _get_action(self, action):
        
        return_action = action
        if self.partial_update_is_update and action == 'partial_update':
            return_action = 'update'
        return return_action
955684
def __execute_steps_by_action(self, context, action):
        
        if len(self.actions[action]) > 0:
            if action in [ACTIONS_BEFORE_FEATURE, ACTIONS_BEFORE_SCENARIO, ACTIONS_AFTER_FEATURE]:
                self.logger.by_console('\n')
                if action == ACTIONS_BEFORE_SCENARIO:
                    self.scenario_counter += 1
                    self.logger.by_console(
                        "  ------------------ Scenario Nº: %d ------------------" % self.scenario_counter)
                self.logger.by_console('  %s:' % action)
            for item in self.actions[action]:
                self.scenario_error = False
                try:
                    self.__print_step_by_console(item)
                    context.execute_steps(u'''%s%s''' % (GIVEN_PREFIX, self.__remove_prefix(item)))
                    self.logger.debug(u'step defined in pre-actions: %s' % repr(item))
                except Exception as exc:
                    if action in [ACTIONS_BEFORE_FEATURE]:
                        self.feature_error = True
                    elif action in [ACTIONS_BEFORE_SCENARIO]:
                        self.scenario_error = True
                    self.logger.error(exc)
                    break
1003853
def register_action(*args, **kwarg):
    '''
    
    '''
    def decorator(fun):
        KeywordArgumentParser._action_dict[frozenset(args)] = fun
        return fun
    return decorator
403918
def perform(action, workitem)
      @action, @workitem = action, workitem
      send(action)
      write_output('') # Triggers any remaining buffered output to be sent
      run_callbacks
    rescue MaestroDev::Plugin::PluginError => e
      write_output('') # Triggers any remaining buffered output to be sent
      set_error(e.message)
    rescue Exception => e
      write_output('') # Triggers any remaining buffered output to be sent
      lowerstack = e.backtrace.find_index(caller[0])
      stack = lowerstack ? e.backtrace[0..lowerstack - 1] : e.backtrace
      msg = "Unexpected error executing task: #{e.class} #{e} at\n" + stack.join("\n")
      Maestro.log.warn("#{msg}\nFull stack:\n" + e.backtrace.join("\n"))

      # Let user-supplied exception handler do its thing
      handle_exception(e)
      set_error(msg)
    ensure
      # Older agents expected this method to *maybe* return something
      # .. something that no longer exists, but if we return anything
      # it will be *wrong* :P
      return nil
    end
1041164
def build_action(self, runnable, regime, action):
        

        if isinstance(action, StateAssignment):
            return self.build_state_assignment(runnable, regime, action)
        if isinstance(action, EventOut):
            return self.build_event_out(action)
        if isinstance(action, Transition):
            return self.build_transition(action)
        else:
            return ['pass']
849857
def run(self, f, *args, **kwargs):
        
        parent = _ACTION_CONTEXT.set(self)
        try:
            return f(*args, **kwargs)
        finally:
            _ACTION_CONTEXT.reset(parent)
389601
def as_view(cls, action_map=None, **initkwargs):
        

        # Needs to re-implement the method but contains all the things the parent does.
        if not action_map:  # actions must not be empty
            raise TypeError("action_map is a required argument.")

        def view(request):
            self = cls(**initkwargs)
            self.request = request
            self.lookup_url_kwargs = self.request.matchdict
            self.action_map = action_map
            self.action = self.action_map.get(self.request.method.lower())

            for method, action in action_map.items():
                handler = getattr(self, action)
                setattr(self, method, handler)

            return self.dispatch(self.request, **self.request.matchdict)

        return view
634121
def action_getattr():
    

    def action_getattr(_value, context, **_params):
        value = getattr(context["action"], context["key"])
        return _attr(value)

    return action_getattr
679395
def action(
        self,
        intent_name,
        is_fallback=False,
        mapping={},
        convert={},
        default={},
        with_context=[],
        events=[],
        *args,
        **kw
    ):
        

        def decorator(f):
            action_funcs = self._intent_action_funcs.get(intent_name, [])
            action_funcs.append(f)
            self._intent_action_funcs[intent_name] = action_funcs

            self._intent_mappings[intent_name] = mapping
            self._intent_converts[intent_name] = convert
            self._intent_defaults[intent_name] = default
            self._intent_fallbacks[intent_name] = is_fallback
            self._intent_events[intent_name] = events
            self._register_context_to_func(intent_name, with_context)

            @wraps(f)
            def wrapper(*args, **kw):
                self._flask_assitant_view_func(*args, **kw)

            return f

        return decorator
217221
def register(action):
        
        if isinstance(action, str):
            Action.register(Action(action))
        elif isinstance(action, Action):
            Action.registered.add(action)
        else:
            for a in action:
                Action.register(a)
1072607
def register_action(self, action):
        
        assert action.value not in self.actions
        self.actions[action.value] = action
512848
def do_action(self, action, objects):
        
        transitioned = []
        ActionHandlerPool.get_instance().queue_pool()
        for obj in objects:
            obj = api.get_object(obj)
            success, message = do_action_for(obj, action)
            if success:
                transitioned.append(obj)
        ActionHandlerPool.get_instance().resume()
        return transitioned
1262628
function dispatch($action_name) {
        if (method_exists($this, '_init')) {
            $this->_init();
        }
        $action = self::getActionMethodName($action_name);
        if (method_exists($this, $action)) {
            return $this->$action();
        } else {
            throw new NoActionException;
        }
    }
464938
def _get_action(self, action):
        

        # If we don't have an action named that, bail out
        if action not in self.wsgi_actions:
            return None

        # Generate an ActionDescriptor if necessary
        if action not in self.wsgi_descriptors:
            self.wsgi_descriptors[action] = actions.ActionDescriptor(
                self.wsgi_actions[action],
                self.wsgi_extensions.get(action, []),
                self.wsgi_resp_type)

        # OK, return the method descriptor
        return self.wsgi_descriptors[action]
30331
def action_setattr():
    

    def action_setattr(value, context, **_params):
        setattr(context["action"], context["key"], value)
        return _attr()

    return action_setattr
54016
def performAction(self, action):
        
        self._lastAction = []

        # Markups chosen for each generator.
        actions = self._allActions[action]

        n = self.numOffbids * len(self.generators)
        markups = actions[:n]
        withholds = actions[n:]

#        print "ALL ACTIONS:", self._allActions
#        print "ACTIONS:", markups, withholds

        self._offbid(markups, withholds)