(self, trigger, source, dest, conditions=None,
                       unless=None, before=None, after=None, prepare=None, **kwargs)
Create a new Transition instance and add it to the internal list.
        Args:
            trigger (str): The name of the method that will trigger the
                transition. This will be attached to the currently specified
                model (e.g., passing trigger='advance' will create a new
                advance() method in the model that triggers the transition.)
            source(str or list): The name of the source state--i.e., the state we
                are transitioning away from. This can be a single state, a
                list of states or an asterisk for all states.
            dest (str): The name of the destination State--i.e., the state
                we are transitioning into. This can be a single state or an
                equal sign to specify that the transition should be reflexive
                so that the destination will be the same as the source for
                every given source. If dest is None, this transition will be
                an internal transition (exit/enter callbacks won't be processed).
            conditions (str or list): Condition(s) that must pass in order
                for the transition to take place. Either a list providing the
                name of a callable, or a list of callables. For the transition
                to occur, ALL callables must return True.
            unless (str or list): Condition(s) that must return False in order
                for the transition to occur. Behaves just like conditions arg
                otherwise.
            before (str or list): Callables to call before the transition.
            after (str or list): Callables to call after the transition.
            prepare (str or list): Callables to call when the trigger is activated
            **kwargs: Additional arguments which can be passed to the created transition.
                This is useful if you plan to extend Machine.Transition and require more parameters.
Create a new Transition instance and add it to the internal list.
        Args:
            trigger (str): The name of the method that will trigger the
                transition. This will be attached to the currently specified
                model (e.g., passing trigger='advance' will create a new
                advance() method in the model that triggers the transition.)
            source(str or list): The name of the source state--i.e., the state we
                are transitioning away from. This can be a single state, a
                list of states or an asterisk for all states.
            dest (str): The name of the destination State--i.e., the state
                we are transitioning into. This can be a single state or an
                equal sign to specify that the transition should be reflexive
                so that the destination will be the same as the source for
                every given source. If dest is None, this transition will be
                an internal transition (exit/enter callbacks won't be processed).
            conditions (str or list): Condition(s) that must pass in order
                for the transition to take place. Either a list providing the
                name of a callable, or a list of callables. For the transition
                to occur, ALL callables must return True.
            unless (str or list): Condition(s) that must return False in order
                for the transition to occur. Behaves just like conditions arg
                otherwise.
            before (str or list): Callables to call before the transition.
            after (str or list): Callables to call after the transition.
            prepare (str or list): Callables to call when the trigger is activated
            **kwargs: Additional arguments which can be passed to the created transition.
                This is useful if you plan to extend Machine.Transition and require more parameters.
Create a new Transition instance and add it to the internal list . Args : trigger ( str ) : The name of the method that will trigger the transition . This will be attached to the currently specified model ( e . g . passing trigger = advance will create a new advance () method in the model that triggers the transition . ) source ( str or list ) : The name of the source state -- i . e . the state we are transitioning away from . This can be a single state a list of states or an asterisk for all states . dest ( str ) : The name of the destination State -- i . e . the state we are transitioning into . This can be a single state or an equal sign to specify that the transition should be reflexive so that the destination will be the same as the source for every given source . If dest is None this transition will be an internal transition ( exit / enter callbacks won t be processed ) . conditions ( str or list ) : Condition ( s ) that must pass in order for the transition to take place . Either a list providing the name of a callable or a list of callables . For the transition to occur ALL callables must return True . unless ( str or list ) : Condition ( s ) that must return False in order for the transition to occur . Behaves just like conditions arg otherwise . before ( str or list ) : Callables to call before the transition . after ( str or list ) : Callables to call after the transition . prepare ( str or list ) : Callables to call when the trigger is activated ** kwargs : Additional arguments which can be passed to the created transition . This is useful if you plan to extend Machine . Transition and require more parameters .
def add_transition(self, trigger, source, dest, conditions=None,
                       unless=None, before=None, after=None, prepare=None, **kwargs):
        """ Create a new Transition instance and add it to the internal list.
        Args:
            trigger (str): The name of the method that will trigger the
                transition. This will be attached to the currently specified
                model (e.g., passing trigger='advance' will create a new
                advance() method in the model that triggers the transition.)
            source(str or list): The name of the source state--i.e., the state we
                are transitioning away from. This can be a single state, a
                list of states or an asterisk for all states.
            dest (str): The name of the destination State--i.e., the state
                we are transitioning into. This can be a single state or an
                equal sign to specify that the transition should be reflexive
                so that the destination will be the same as the source for
                every given source. If dest is None, this transition will be
                an internal transition (exit/enter callbacks won't be processed).
            conditions (str or list): Condition(s) that must pass in order
                for the transition to take place. Either a list providing the
                name of a callable, or a list of callables. For the transition
                to occur, ALL callables must return True.
            unless (str or list): Condition(s) that must return False in order
                for the transition to occur. Behaves just like conditions arg
                otherwise.
            before (str or list): Callables to call before the transition.
            after (str or list): Callables to call after the transition.
            prepare (str or list): Callables to call when the trigger is activated
            **kwargs: Additional arguments which can be passed to the created transition.
                This is useful if you plan to extend Machine.Transition and require more parameters.
        """
        if trigger == self.model_attribute:
            raise ValueError("Trigger name cannot be same as model attribute name.")
        if trigger not in self.events:
            self.events[trigger] = self._create_event(trigger, self)
            for model in self.models:
                self._add_trigger_to_model(trigger, model)

        if source == self.wildcard_all:
            source = list(self.states.keys())
        else:
            # states are checked lazily which means we will only raise exceptions when the passed state
            # is a State object because of potential confusion (see issue #155 for more details)
            source = [s.name if isinstance(s, State) and self._has_state(s, raise_error=True) or hasattr(s, 'name') else
                      s for s in listify(source)]

        for state in source:
            if dest == self.wildcard_same:
                _dest = state
            elif dest is not None:
                if isinstance(dest, State):
                    _ = self._has_state(dest, raise_error=True)
                _dest = dest.name if hasattr(dest, 'name') else dest
            else:
                _dest = None
            _trans = self._create_transition(state, _dest, conditions, unless, before,
                                             after, prepare, **kwargs)
            self.events[trigger].add_transition(_trans)
def add_transition ( self , trigger , source , dest , conditions = None , unless = None , before = None , after = None , prepare = None , * * kwargs ) : if trigger == self . model_attribute : raise ValueError ( "Trigger name cannot be same as model attribute name." ) if trigger not in self . events : self . events [ trigger ] = self . _create_event ( trigger , self ) for model in self . models : self . _add_trigger_to_model ( trigger , model ) if source == self . wildcard_all : source = list ( self . states . keys ( ) ) else : # states are checked lazily which means we will only raise exceptions when the passed state # is a State object because of potential confusion (see issue #155 for more details) source = [ s . name if isinstance ( s , State ) and self . _has_state ( s , raise_error = True ) or hasattr ( s , 'name' ) else s for s in listify ( source ) ] for state in source : if dest == self . wildcard_same : _dest = state elif dest is not None : if isinstance ( dest , State ) : _ = self . _has_state ( dest , raise_error = True ) _dest = dest . name if hasattr ( dest , 'name' ) else dest else : _dest = None _trans = self . _create_transition ( state , _dest , conditions , unless , before , after , prepare , * * kwargs ) self . events [ trigger ] . add_transition ( _trans )