MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / after_soft_rollback

Method after_soft_rollback

lib/sqlalchemy/orm/events.py:1900–1926  ·  view source on GitHub ↗

Execute after any rollback has occurred, including "soft" rollbacks that don't actually emit at the DBAPI level. 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 rollba

(
        self, session: Session, previous_transaction: SessionTransaction
    )

Source from the content-addressed store, hash-verified

1898 """
1899
1900 def after_soft_rollback(
1901 self, session: Session, previous_transaction: SessionTransaction
1902 ) -> None:
1903 """Execute after any rollback has occurred, including "soft"
1904 rollbacks that don't actually emit at the DBAPI level.
1905
1906 This corresponds to both nested and outer rollbacks, i.e.
1907 the innermost rollback that calls the DBAPI's
1908 rollback() method, as well as the enclosing rollback
1909 calls that only pop themselves from the transaction stack.
1910
1911 The given :class:`.Session` can be used to invoke SQL and
1912 :meth:`.Session.query` operations after an outermost rollback
1913 by first checking the :attr:`.Session.is_active` flag::
1914
1915 @event.listens_for(Session, "after_soft_rollback")
1916 def do_something(session, previous_transaction):
1917 if session.is_active:
1918 session.execute(text("select * from some_table"))
1919
1920 :param session: The target :class:`.Session`.
1921 :param previous_transaction: The :class:`.SessionTransaction`
1922 transactional marker object which was just closed. The current
1923 :class:`.SessionTransaction` for the given :class:`.Session` is
1924 available via the :attr:`.Session.transaction` attribute.
1925
1926 """
1927
1928 def before_flush(
1929 self,

Callers 1

rollbackMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected