summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/attributes.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-01-20 00:53:47 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-01-20 00:53:47 +0000
commit8a01ba0425823a99543dcf6f8f9b86dbac2cfd2c (patch)
tree2813ec47b3cf1e7b6fbeb3cc6cfa8f0423f7552b /lib/sqlalchemy/attributes.py
parent2808d04dd8faec0b7a8ac280ff23674cd0a36fc6 (diff)
downloadsqlalchemy-8a01ba0425823a99543dcf6f8f9b86dbac2cfd2c.tar.gz
unset attributes on an object instance just return None instead of raising attributeerror
Diffstat (limited to 'lib/sqlalchemy/attributes.py')
-rw-r--r--lib/sqlalchemy/attributes.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/sqlalchemy/attributes.py b/lib/sqlalchemy/attributes.py
index f87f4de9d..29a79edd2 100644
--- a/lib/sqlalchemy/attributes.py
+++ b/lib/sqlalchemy/attributes.py
@@ -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."""