OpenStack Common DB Code
Go to file
Victor Stinner 2e79681670 Fix sqlalchemy.ModelBase.__contains__() behaviour
Currently, sqlalchemy.ModelBase.__contains__() catches any exception,
and by doing that, it hides real bugs. For example, a Nova unit test
raises the following error, but __contains__() simply returns False:

    sqlalchemy.orm.exc.DetachedInstanceError: Parent instance
    <InstanceExtra at 0x7fea635bc5f8> is not bound to a Session;
    deferred load operation of attribute 'pci_requests' cannot proceed

On Python 3, hasattr() calls getattr(): it returns True if getattr()
succeeds, False if getattr() raises an AttributeError, or passes
through the exception, if getattr() failed for a different reason.

On Python 2, hasattr() also calls getattr(), but it catches *any*
exception.

This change replaces hasattr() with getattr(), and it only catches
AttributeError as Python 3, so passes through sqlalchemy exceptions.

Add an unit test to test the new behaviour.

Closes-Bug: #1469225

Change-Id: If9c3ccc03f1dc9746936b0b83ea132508491e577
2015-06-26 19:02:53 +03:00
doc/source Switch from MySQL-python to PyMySQL 2015-06-18 15:42:23 +03:00
oslo_db Fix sqlalchemy.ModelBase.__contains__() behaviour 2015-06-26 19:02:53 +03:00
oslo.db/locale Imported Translations from Transifex 2015-06-24 06:21:06 +00:00
tools Remove run_cross_tests.sh 2015-05-05 19:39:49 +00:00
.coveragerc Fix the graduate.sh script result 2014-04-18 11:33:16 +03:00
.gitignore Clean up documentation 2014-09-04 16:27:00 -04:00
.gitreview Fix .gitreview for oslo.db 2014-04-30 16:55:51 +02:00
.mailmap Fix the graduate.sh script result 2014-04-18 11:33:16 +03:00
.testr.conf Move files out of the namespace package 2014-12-24 13:28:48 +02:00
babel.cfg Fix the graduate.sh script result 2014-04-18 11:33:16 +03:00
CONTRIBUTING.rst Switch from MySQL-python to PyMySQL 2015-06-18 15:42:23 +03:00
HACKING.rst Add doc8 to tox environment docs 2014-09-01 11:40:08 +02:00
LICENSE Fix the graduate.sh script result 2014-04-18 11:33:16 +03:00
MANIFEST.in Fix the graduate.sh script result 2014-04-18 11:33:16 +03:00
openstack-common.conf Remove run_cross_tests.sh 2015-05-05 19:39:49 +00:00
README.rst Switch badges from 'pypip.in' to 'shields.io' 2015-06-11 20:42:31 -07:00
requirements.txt Updated from global requirements 2015-06-24 14:45:32 +00:00
setup.cfg Remove oslo namespace package 2015-06-21 20:54:10 +00:00
setup.py Updated from global requirements 2015-06-22 08:27:02 +00:00
test-requirements.txt Updated from global requirements 2015-06-22 08:27:02 +00:00
tox.ini Switch from MySQL-python to PyMySQL 2015-06-18 15:42:23 +03:00

oslo.db

Latest Version

Downloads

The oslo db (database) handling library, it provides database connectivity to different database backends and various other helper utils.