MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / before_flush

Function before_flush

examples/versioned_rows/versioned_map.py:50–61  ·  view source on GitHub ↗

Apply the new_version() method of objects which are marked as dirty during a flush.

(session, flush_context, instances)

Source from the content-addressed store, hash-verified

48
49@event.listens_for(Session, "before_flush")
50def before_flush(session, flush_context, instances):
51 """Apply the new_version() method of objects which are
52 marked as dirty during a flush.
53
54 """
55 for instance in session.dirty:
56 if hasattr(instance, "new_version") and session.is_modified(instance):
57 # make it transient
58 instance.new_version(session)
59
60 # re-add
61 session.add(instance)
62
63
64Base = declarative_base()

Callers

nothing calls this directly

Calls 3

is_modifiedMethod · 0.45
new_versionMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected