On 24 Mai, 20:16, Matthew Wilson <m...@tplus1.com> wrote: > I'm working on a really simple workflow for my bug tracker. I want > filed bugs to start in an UNSTARTED status. From there, they can go to > STARTED. > > From STARTED, bugs can go to FINISHED or ABANDONED. > > I know I can easily hard-code this stuff into some if-clauses, but I > expect to need to add a lot more statuses over time and a lot more > relationships. > > This seems like a crude state diagram. So, has anyone on this list done > similar work? > > How should I design this so that users can add arbitrary new statuses > and then define how to get to and from those statuses? > > TIA > > MAtt
General answer: you can encode finite state machines as grammars. States as non-terminals and transition labels as terminals: UNSTARTED: 'start' STARTED STARTED: 'ok' FINISHED | 'cancel' ABANDONED ABANDONED: 'done' FINISHED: 'done' In some sense each state-machine is also a little language. -- http://mail.python.org/mailman/listinfo/python-list