Intercept the "detached to persistent" transition for a specific object. This event is a specialization of the :meth:`.SessionEvents.after_attach` event which is only invoked for this specific transition. It is invoked typically during the :meth:`.Session.ad
(self, session: Session, instance: _O)
| 2233 | |
| 2234 | @_lifecycle_event |
| 2235 | def detached_to_persistent(self, session: Session, instance: _O) -> None: |
| 2236 | """Intercept the "detached to persistent" transition for a specific |
| 2237 | object. |
| 2238 | |
| 2239 | This event is a specialization of the |
| 2240 | :meth:`.SessionEvents.after_attach` event which is only invoked |
| 2241 | for this specific transition. It is invoked typically during the |
| 2242 | :meth:`.Session.add` call, as well as during the |
| 2243 | :meth:`.Session.delete` call if the object was not previously |
| 2244 | associated with the |
| 2245 | :class:`.Session` (note that an object marked as "deleted" remains |
| 2246 | in the "persistent" state until the flush proceeds). |
| 2247 | |
| 2248 | .. note:: |
| 2249 | |
| 2250 | If the object becomes persistent as part of a call to |
| 2251 | :meth:`.Session.delete`, the object is **not** yet marked as |
| 2252 | deleted when this event is called. To detect deleted objects, |
| 2253 | check the ``deleted`` flag sent to the |
| 2254 | :meth:`.SessionEvents.persistent_to_detached` to event after the |
| 2255 | flush proceeds, or check the :attr:`.Session.deleted` collection |
| 2256 | within the :meth:`.SessionEvents.before_flush` event if deleted |
| 2257 | objects need to be intercepted before the flush. |
| 2258 | |
| 2259 | :param session: target :class:`.Session` |
| 2260 | |
| 2261 | :param instance: the ORM-mapped instance being operated upon. |
| 2262 | |
| 2263 | .. seealso:: |
| 2264 | |
| 2265 | :ref:`session_lifecycle_events` |
| 2266 | |
| 2267 | """ |
| 2268 | |
| 2269 | @_lifecycle_event |
| 2270 | def loaded_as_persistent(self, session: Session, instance: _O) -> None: |
no outgoing calls