Closed andrewvaughan closed 1 year ago
Upon further review, it's because I had __
in front of the class names as private methods... not sure if that's resolvable with this scope. This may be closeable.
Hello @andrewvaughan,
when passed as strings, callbacks will be resolved during runtime. This does not work with double underscore functions since their names will get obfuscated. If you NEED double underscore functions you could pass them by reference:
from transitions import Machine
class Automator:
def __init__(self):
self.__machine = Machine(
model=self,
before_state_change=self.__check_login,
on_exception=self.__handle_exception,
send_event=True,
states=['starting'],
initial='starting'
)
# ... removed for brevity ...
def __check_login(self, event):
print("CHECKING LOGIN")
def __handle_exception(self, event):
print(f"Exception: {event.error}")
m = Automator()
m.to_starting()
Using the
NarcolepticSuperhero
pattern fails when trying to also seton_exception
orbefore_state_change
callbacks:This creates a cascade of errors when attempting to be called:
It seems like the
Machine
cannot resolve callbacks from__init__
when they're created in theNarcolepticSuperhero
pattern.