I’m looking to hook into the model creation cycle for sqlalchemy models. For example on create or on save (like in the Ruby ORM ActiveRecord, in fact I’m moving a model from ActiveRecord to SqlAlchemy).
Events looks like what I need: http://docs.sqlalchemy.org/en/rel_0_7/core/event.html, but I haven’t found more detailed examples, yet. I’d like to hear someone’s experience with this.
Are there similar facilities in sqlalchemy for doing things with a model/instance based on certain cues, e.g. after_create?
Events are pretty simple once you get the hang of it.
Here is a quick example using events
Alternately, you can use decorators: