Merge lp:~ewanmellor/nova/lp652103 into lp:~hudson-openstack/nova/trunk

Proposed by Ewan Mellor
Status: Merged
Approved by: Jay Pipes
Approved revision: 311
Merged at revision: 312
Proposed branch: lp:~ewanmellor/nova/lp652103
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 19 lines (+2/-1)
1 file modified
nova/db/sqlalchemy/api.py (+2/-1)
To merge this branch: bzr merge lp:~ewanmellor/nova/lp652103
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Review via email: mp+37137@code.launchpad.net

Description of the change

  Bug #652103: NameError in exception handler in sqlalchemy API layer

  Fix reference to NoResultFound.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

straightforward fix...setting to Approve.

review: Approve
Revision history for this message
Jay Pipes (jaypipes) wrote :

Come to think of it, couldn't you just extend the from sqlalchemy.exc import IntegrityError to include NoResultFound as well, instead of adding a whole other import line?

Revision history for this message
Ewan Mellor (ewanmellor) wrote :

HACKING says "thou shalt not import more than one module per line". I'm
just doing what I'm told ;-)

On Thu, Sep 30, 2010 at 05:09:39PM +0100, Jay Pipes wrote:

> Come to think of it, couldn't you just extend the from sqlalchemy.exc import IntegrityError to include NoResultFound as well, instead of adding a whole other import line?
> --
> https://code.launchpad.net/~ewanmellor/nova/lp652103/+merge/37137
> You are the owner of lp:~ewanmellor/nova/lp652103.

Revision history for this message
Jay Pipes (jaypipes) wrote :

:) why yes you are, Ewan.

Revision history for this message
Todd Willey (xtoddx) wrote :

Those imports need to be cleaned up in general to import modules instead of objects, per HACKIKNG. But I don't think anybody is too concerned about it. Working right is much more important.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/db/sqlalchemy/api.py'
--- nova/db/sqlalchemy/api.py 2010-09-29 02:38:15 +0000
+++ nova/db/sqlalchemy/api.py 2010-09-30 15:03:40 +0000
@@ -30,6 +30,7 @@
30from sqlalchemy import or_30from sqlalchemy import or_
31from sqlalchemy.exc import IntegrityError31from sqlalchemy.exc import IntegrityError
32from sqlalchemy.orm import joinedload_all32from sqlalchemy.orm import joinedload_all
33from sqlalchemy.orm.exc import NoResultFound
33from sqlalchemy.sql import exists, func34from sqlalchemy.sql import exists, func
3435
35FLAGS = flags.FLAGS36FLAGS = flags.FLAGS
@@ -348,7 +349,7 @@
348 ).filter_by(address=address349 ).filter_by(address=address
349 ).filter_by(deleted=False350 ).filter_by(deleted=False
350 ).one()351 ).one()
351 except exc.NoResultFound:352 except NoResultFound:
352 new_exc = exception.NotFound("No model for address %s" % address)353 new_exc = exception.NotFound("No model for address %s" % address)
353 raise new_exc.__class__, new_exc, sys.exc_info()[2]354 raise new_exc.__class__, new_exc, sys.exc_info()[2]
354355