Some state machines coded in python for a web script