Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Classe « SessionEvents »

Méthode sqlalchemy.orm.SessionEvents.persistent_to_detached

Signature de la méthode persistent_to_detached

def persistent_to_detached(self, session, instance) 

Description

persistent_to_detached.__doc__

Intercept the "persistent to detached" transition for a specific object.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeSessionOrFactory, 'persistent_to_detached')
        def receive_persistent_to_detached(session, instance):
            "listen for the 'persistent_to_detached' event"

            # ... (event handling logic) ...


This event is invoked when a persistent object is evicted
from the session.  There are many conditions that cause this
to happen, including:

* using a method such as :meth:`.Session.expunge`
  or :meth:`.Session.close`

* Calling the :meth:`.Session.rollback` method, when the object
  was part of an INSERT statement for that session's transaction


:param session: target :class:`.Session`

:param instance: the ORM-mapped instance being operated upon.

:param deleted: boolean.  If True, indicates this object moved
 to the detached state because it was marked as deleted and flushed.


.. versionadded:: 1.1

.. seealso::

    :ref:`session_lifecycle_events`