-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nothing like set_state("string") for transitions #134
Comments
Can you elaborate? What would the expected behavior be? It's true that accessing |
On re-reading, maybe I'm overthinking this. Do you just mean you want to fire a trigger based on a string name? I.e., instead of
I don't think you need to Note also that the |
Yes, I just want to fire a trigger based on a string name. Thank you, Jest ran some tests and Sure not critical though, since there is an easy existing workaround. |
Well, one limitation (though it's actually a feature and not a bug) of On further reflection though, I do think it probably makes sense to have an easy way to trigger events from the model by passing a string. While the approach I suggested above works fine, the user shouldn't really have to reach inside the model that way. @aleneum and @wtgee, any objections to my adding a |
I actually have a private method called My method does also offer up a default transition if the requested transition can't be found. Not sure if we would want to build that functionality into it as it would be easy enough to write if someone needed it, but worth considering. |
Easy to implement and maintain. Since this seems to add convenience I am all for it 👍
This could be the second candidate for a model extension module: |
👍 for the simple method. Let's leave the default until later. I don't think it would need a full extension module and I would be a little sceptical to start making too many extensions without a clear need although am not actually opposed. |
I was planning to get to this once the multiple-models branch was merged, but thanks for taking care of it! :) |
It was a welcome way to distract myself from something I (don't) want to do today ;). |
Still I did not find a method in core.py to reach a transition via string. In my opinion a necessary feature to use transitions for APIs where triggers get passed via string.
Currently I'm doing
def _set_transition(self, name): eval('self.' +name+'()')
self._set_transition("string")
to all my classes. But It would be great to have
self.machine.set_transition("string")
instead.
The text was updated successfully, but these errors were encountered: