if history.has_changes():
    value = attribute_state.value
old_value = get_old_value(attribute_state)
handler = registry.get(mapper_property)
if handler:
    handler(object_, value, old_value)

def on_after_flush(session, flush_context):
    changed_objects = session.new.union(session.dirty)
for o in changed_objects:
    trigger_attribute_change_events(o)
event.listen(session, 'after_flush', on_after_flush)
How can I get a SQLAlchemy ORM object's previous state after a db update?