jtushman / state_machine

Python State Machine for humans
MIT License
400 stars 31 forks source link

Tests failing (mongoengine) - use of a metaclass #25

Closed bagerard closed 1 year ago

bagerard commented 8 years ago

Few tests are failing when ran against the latest mongoengine (0.10.5). After some debugging, it looks like it breaks some mongoengine internals when it uses type(...) to instantiate the modified class.

clazz = type(class_name, original_class.__bases__, class_dict)

This makes the Document.id field not in line with the object's pk after a .save(). I tried to fix it but ended up re-writing the state machine using a metaclass and it now works wonderfully. Let me know in case you are interested in a PR.