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_soft_rollback

Signature de la méthode after_soft_rollback

def after_soft_rollback(self, session, previous_transaction) 

Description

after_soft_rollback.__doc__

Execute after any rollback has occurred, including "soft"
rollbacks that don't actually emit at the DBAPI level.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeSessionOrFactory, 'after_soft_rollback')
        def receive_after_soft_rollback(session, previous_transaction):
            "listen for the 'after_soft_rollback' event"

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


This corresponds to both nested and outer rollbacks, i.e.
the innermost rollback that calls the DBAPI's
rollback() method, as well as the enclosing rollback
calls that only pop themselves from the transaction stack.

The given :class:`.Session` can be used to invoke SQL and
:meth:`.Session.query` operations after an outermost rollback
by first checking the :attr:`.Session.is_active` flag::

    @event.listens_for(Session, "after_soft_rollback")
    def do_something(session, previous_transaction):
        if session.is_active:
            session.execute("select * from some_table")

:param session: The target :class:`.Session`.
:param previous_transaction: The :class:`.SessionTransaction`
 transactional marker object which was just closed.   The current
 :class:`.SessionTransaction` for the given :class:`.Session` is
 available via the :attr:`.Session.transaction` attribute.