summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/mutable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-07-01 11:32:07 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-07-01 11:32:07 -0400
commit409a95adf44f577a204114469ff414bebefca293 (patch)
tree90429da5eba44a8073125c89a9927426083fd553 /lib/sqlalchemy/ext/mutable.py
parent9ae8de1f65c89f33f4ffae33023e481955f72244 (diff)
downloadsqlalchemy-409a95adf44f577a204114469ff414bebefca293.tar.gz
- Fixed bug in the mutable extension whereby
if None or a non-corresponding type were set, an error would be raised. None is now accepted which assigns None to all attributes, illegal values raise ValueError.
Diffstat (limited to 'lib/sqlalchemy/ext/mutable.py')
-rw-r--r--lib/sqlalchemy/ext/mutable.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py
index b31710ca8..ece7e3ad4 100644
--- a/lib/sqlalchemy/ext/mutable.py
+++ b/lib/sqlalchemy/ext/mutable.py
@@ -347,6 +347,16 @@ class MutableBase(object):
return weakref.WeakKeyDictionary()
@classmethod
+ def coerce(cls, key, value):
+ """Given a value, coerce it into this type.
+
+ By default raises ValueError.
+ """
+ if value is None:
+ return None
+ raise ValueError("Attribute '%s' does not accept objects of type %s" % (key, type(value)))
+
+ @classmethod
def _listen_on_attribute(cls, attribute, coerce, parent_cls):
"""Establish this type as a mutation listener for the given
mapped descriptor.
@@ -424,16 +434,6 @@ class Mutable(MutableBase):
flag_modified(parent, key)
@classmethod
- def coerce(cls, key, value):
- """Given a value, coerce it into this type.
-
- By default raises ValueError.
- """
- if value is None:
- return None
- raise ValueError("Attribute '%s' does not accept objects of type %s" % (key, type(value)))
-
- @classmethod
def associate_with_attribute(cls, attribute):
"""Establish this type as a mutation listener for the given
mapped descriptor.