def on_foo_created(mapper, connection, foo_obj):
    foo_obj.foo_attr = get_new_value()
event.listen(Foo, 'before_insert', on_foo_created)
Change object's attribute on session commit - Flask SQLAlchemy