From: Jason Kirtland Date: Thu, 1 Nov 2007 16:36:50 +0000 (+0000) Subject: Fixed truth-evaluation of mapped objects (part of [ticket:676] X-Git-Tag: rel_0_4_1~81 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ca73fbab87d271ed9e63f8f4f0d13036ac46279a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Fixed truth-evaluation of mapped objects (part of [ticket:676] --- diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 1855a24b02..189cd52ee0 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -689,7 +689,9 @@ class InstanceDict(UserDict.UserDict): def __getitem__(self, key): state = self.data[key] - o = state.obj() or state._check_resurrect(self) + o = state.obj() + if o is None: + o = state._check_resurrect(self) if o is None: raise KeyError, key return o @@ -697,7 +699,9 @@ class InstanceDict(UserDict.UserDict): def __contains__(self, key): try: state = self.data[key] - o = state.obj() or state._check_resurrect(self) + o = state.obj() + if o is None: + o = state._check_resurrect(self) except KeyError: return False return o is not None