From: Mike Bayer Date: Fri, 20 Jan 2006 00:53:47 +0000 (+0000) Subject: unset attributes on an object instance just return None instead of raising attributeerror X-Git-Tag: rel_0_1_0~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a01ba0425823a99543dcf6f8f9b86dbac2cfd2c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git unset attributes on an object instance just return None instead of raising attributeerror --- diff --git a/lib/sqlalchemy/attributes.py b/lib/sqlalchemy/attributes.py index f87f4de9de..29a79edd24 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."""