pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.68k stars 530 forks source link

Transition with 3 conditions, if the first fail go to "Invalid", if one the the two other fail goes to "Rollbacked" #423

Closed Jr0ussy closed 4 years ago

Jr0ussy commented 4 years ago

Hi,

The code I have right now is if any conditions fail, it will go to Rollbacked, but I want that is if the first fail to go to Invalid, how can I do that?

Here the code:

self.machine.add_transition(trigger='deployment', source='Valid', dest='Deployed', conditions=['validate_before', 'run_deployment', 'validate_after'], after='audit') self.machine.add_transition(trigger='deployment', source='Valid', dest='Rollbacked', conditions=['run_rollback', 'validate_rollback'], after='audit') self.machine.add_transition(trigger='deployment', source='Valid', dest='Rollback_failed', after='audit')

Jr0ussy commented 4 years ago

I found myself how to do it.