]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
unset attributes on an object instance just return None instead of raising attributeerror
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 20 Jan 2006 00:53:47 +0000 (00:53 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 20 Jan 2006 00:53:47 +0000 (00:53 +0000)
lib/sqlalchemy/attributes.py

index f87f4de9deb09d47dbe749007dd4096abc3ba582..29a79edd2427576e6eae6cbea26f702d0b5e6442 100644 (file)
@@ -267,12 +267,14 @@ class AttributeManager(object):
         return CallableProp(self, func, obj, key, uselist, **kwargs)
         
     def get_attribute(self, obj, key, **kwargs):
-        """returns the value of an object's scalar attribiute."""
+        """returns the value of an object's scalar attribute, or None if
+        its not defined on the object (since we are a property accessor, this
+        is considered more appropriate than raising AttributeError)."""
         h = self.get_history(obj, key, **kwargs)
         try:
             return h.getattr()
         except KeyError:
-            raise AttributeError(key)
+            return None
 
     def get_list_attribute(self, obj, key, **kwargs):
         """returns the value of an object's list-based attribute."""