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
1=== modified file 'nova/db/sqlalchemy/api.py'
2--- nova/db/sqlalchemy/api.py 2010-09-29 02:38:15 +0000
3+++ nova/db/sqlalchemy/api.py 2010-09-30 15:03:40 +0000
4@@ -30,6 +30,7 @@
5 from sqlalchemy import or_
6 from sqlalchemy.exc import IntegrityError
7 from sqlalchemy.orm import joinedload_all
8+from sqlalchemy.orm.exc import NoResultFound
9 from sqlalchemy.sql import exists, func
10
11 FLAGS = flags.FLAGS
12@@ -348,7 +349,7 @@
13 ).filter_by(address=address
14 ).filter_by(deleted=False
15 ).one()
16- except exc.NoResultFound:
17+ except NoResultFound:
18 new_exc = exception.NotFound("No model for address %s" % address)
19 raise new_exc.__class__, new_exc, sys.exc_info()[2]
20