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_transaction_end

Signature de la méthode after_transaction_end

def after_transaction_end(self, session, transaction) 

Description

after_transaction_end.__doc__

Execute when the span of a :class:`.SessionTransaction` ends.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeSessionOrFactory, 'after_transaction_end')
        def receive_after_transaction_end(session, transaction):
            "listen for the 'after_transaction_end' event"

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


This event differs from :meth:`~.SessionEvents.after_commit`
in that it corresponds to all :class:`.SessionTransaction`
objects in use, including those for nested transactions
and subtransactions, and is always matched by a corresponding
:meth:`~.SessionEvents.after_transaction_create` event.

:param session: the target :class:`.Session`.
:param transaction: the target :class:`.SessionTransaction`.

 To detect if this is the outermost
 :class:`.SessionTransaction`, as opposed to a "subtransaction" or a
 SAVEPOINT, test that the :attr:`.SessionTransaction.parent` attribute
 is ``None``::

        @event.listens_for(session, "after_transaction_create")
        def after_transaction_end(session, transaction):
            if transaction.parent is None:
                # work with top-level transaction

 To detect if the :class:`.SessionTransaction` is a SAVEPOINT, use the
 :attr:`.SessionTransaction.nested` attribute::

        @event.listens_for(session, "after_transaction_create")
        def after_transaction_end(session, transaction):
            if transaction.nested:
                # work with SAVEPOINT transaction


.. seealso::

    :class:`.SessionTransaction`

    :meth:`~.SessionEvents.after_transaction_create`