]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixed truth-evaluation of mapped objects (part of [ticket:676]
authorJason Kirtland <jek@discorporate.us>
Thu, 1 Nov 2007 16:36:50 +0000 (16:36 +0000)
committerJason Kirtland <jek@discorporate.us>
Thu, 1 Nov 2007 16:36:50 +0000 (16:36 +0000)
lib/sqlalchemy/orm/attributes.py

index 1855a24b023b3c5c5648bbc0ffcc191dd45a39ef..189cd52ee07cd356a942a4ed95e097258f6b8cd4 100644 (file)
@@ -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