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)
| 2054 | |
| 2055 | @_lifecycle_event |
| 2056 | def before_attach(self, session: Session, instance: _O) -> None: |
| 2057 | """Execute before an instance is attached to a session. |
| 2058 | |
| 2059 | This is called before an add, delete or merge causes |
| 2060 | the object to be part of the session. |
| 2061 | |
| 2062 | .. seealso:: |
| 2063 | |
| 2064 | :meth:`~.SessionEvents.after_attach` |
| 2065 | |
| 2066 | :ref:`session_lifecycle_events` |
| 2067 | |
| 2068 | """ |
| 2069 | |
| 2070 | @_lifecycle_event |
| 2071 | def after_attach(self, session: Session, instance: _O) -> None: |