I got a recommendation to use sqlalchemy-continuum, which seems to do very much what I want out of the box.
By default, the ORM assumes that there is a user column. I do indeed want to save originators of an edit, but the documentation only says “This is how you specify a User class”, without saying anything about how to specify such an object when actually using versioned tables.
How do I specify the User responsible for a transaction? Is there a similar way to add a commit message/reason/citation (a VARCHAR) to each transaction?
If you can get the user from some global scope (like flask.g or flask.request), you can create a plugin, implementing the
transaction_args()
method:See plugins/flask.py or pyramid_plugin.py. You should return primary key value of your User model.
You can save additional data with TransactionMeta plugin in a separate table. There is no documented API for extending the Transaction class itself. It is created by
TransactionFactory
, but that could change in later versions. It is probably a good idea to keep additional data separate.