Apply the new_version() method of objects which are marked as dirty during a flush.
(session, flush_context, instances)
| 48 | |
| 49 | @event.listens_for(Session, "before_flush") |
| 50 | def 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 | |
| 64 | Base = declarative_base() |
nothing calls this directly
no test coverage detected