Add _wrap_db_error() support to SessionTransaction.commit()
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.

Closes-bug: #1370191

Change-Id: Ie0456e6daa86c99cf6fbe56ca5dfd8a618f14232

luogangyi/bcec-nova,luogangyi/bcec-nova