(self, model, initial=None)
Register a model with the state machine, initializing triggers and callbacks.
Register a model with the state machine, initializing triggers and callbacks.
Register a model with the state machine initializing triggers and callbacks .
def add_model(self, model, initial=None):
        """ Register a model with the state machine, initializing triggers and callbacks. """
        models = listify(model)

        if initial is None:
            if self.initial is None:
                raise ValueError("No initial state configured for machine, must specify when adding model.")
            else:
                initial = self.initial

        for mod in models:
            mod = self if mod is self.self_literal else mod
            if mod not in self.models:
                self._checked_assignment(mod, 'trigger', partial(self._get_trigger, mod))

                for trigger in self.events:
                    self._add_trigger_to_model(trigger, mod)

                for state in self.states.values():
                    self._add_model_to_state(state, mod)

                self.set_state(initial, model=mod)
                self.models.append(mod)
def add_model ( self , model , initial = None ) : models = listify ( model ) if initial is None : if self . initial is None : raise ValueError ( "No initial state configured for machine, must specify when adding model." ) else : initial = self . initial for mod in models : mod = self if mod is self . self_literal else mod if mod not in self . models : self . _checked_assignment ( mod , 'trigger' , partial ( self . _get_trigger , mod ) ) for trigger in self . events : self . _add_trigger_to_model ( trigger , mod ) for state in self . states . values ( ) : self . _add_model_to_state ( state , mod ) self . set_state ( initial , model = mod ) self . models . append ( mod )