Add _wrap_db_error() support to SessionTransaction.commit()
This patch adds _wrap_db_error() to the commit()
and rollback() methods of sqlalchemy.orm.session.SessionTransaction,
which is the object that is dealt with when one invokes
code of the form "with session.begin():". The context manager
form does not invoke the commit() method on the
SQLAlchemy Session directly, and instead calls the one
local to the SessionTransaction.
In order to intercept this, we must build a subclass
of SessionTransaction with the appropriate wrapping, and
then patch it into the object that is returned by
Session.begin(), ensuring that it is compatible with
_wrap_db_error().
This whole approach is legacy; newer oslo.db versions
intercept errors at the point at which they occur
via engine events.
Tests are omitted here as we are relying upon the tests
that were added to the corresponding oslo-incubator code.
Reviewed: https:/ /review. openstack. org/124515 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=cac6472fd2a d495d22fe6fad89 a9485cf025c437
Committed: https:/
Submitter: Jenkins
Branch: stable/icehouse
commit cac6472fd2ad495 d22fe6fad89a948 5cf025c437
Author: Mike Bayer <email address hidden>
Date: Fri Sep 26 17:27:53 2014 -0400
Add _wrap_db_error() support to SessionTransact ion.commit( )
This patch adds _wrap_db_error() to the commit() orm.session. SessionTransact ion,
and rollback() methods of sqlalchemy.
which is the object that is dealt with when one invokes
code of the form "with session.begin():". The context manager
form does not invoke the commit() method on the
SQLAlchemy Session directly, and instead calls the one
local to the SessionTransaction.
In order to intercept this, we must build a subclass begin() , ensuring that it is compatible with db_error( ).
of SessionTransaction with the appropriate wrapping, and
then patch it into the object that is returned by
Session.
_wrap_
This whole approach is legacy; newer oslo.db versions
intercept errors at the point at which they occur
via engine events.
Tests are omitted here as we are relying upon the tests
that were added to the corresponding oslo-incubator code.
Closes-bug: #1370191
Change-Id: Ie0456e6daa86c9 9cf6fbe56ca5dfd 8a618f14232