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.after_flush

Signature de la méthode after_flush

def after_flush(self, session, flush_context) 

Description

after_flush.__doc__

Execute after flush has completed, but before commit has been
called.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeSessionOrFactory, 'after_flush')
        def receive_after_flush(session, flush_context):
            "listen for the 'after_flush' event"

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


Note that the session's state is still in pre-flush, i.e. 'new',
'dirty', and 'deleted' lists still show pre-flush state as well
as the history settings on instance attributes.

.. warning:: This event runs after the :class:`.Session` has emitted
   SQL to modify the database, but **before** it has altered its
   internal state to reflect those changes, including that newly
   inserted objects are placed into the identity map.  ORM operations
   emitted within this event such as loads of related items
   may produce new identity map entries that will immediately
   be replaced, sometimes causing confusing results.  SQLAlchemy will
   emit a warning for this condition as of version 1.3.9.

:param session: The target :class:`.Session`.
:param flush_context: Internal :class:`.UOWTransaction` object
 which handles the details of the flush.

.. seealso::

    :meth:`~.SessionEvents.before_flush`

    :meth:`~.SessionEvents.after_flush_postexec`

    :ref:`session_persistence_events`