Execute before an instance is attached to a session. This is called before an add, delete or merge causes the object to be part of the session. .. seealso:: :meth:`~.SessionEvents.after_attach` :ref:`session_lifecycle_events`
(self, session: Session, instance: _O)
| 2043 | |
| 2044 | @_lifecycle_event |
| 2045 | def before_attach(self, session: Session, instance: _O) -> None: |
| 2046 | """Execute before an instance is attached to a session. |
| 2047 | |
| 2048 | This is called before an add, delete or merge causes |
| 2049 | the object to be part of the session. |
| 2050 | |
| 2051 | .. seealso:: |
| 2052 | |
| 2053 | :meth:`~.SessionEvents.after_attach` |
| 2054 | |
| 2055 | :ref:`session_lifecycle_events` |
| 2056 | |
| 2057 | """ |
| 2058 | |
| 2059 | @_lifecycle_event |
| 2060 | def after_attach(self, session: Session, instance: _O) -> None: |