diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-09-02 17:57:35 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-09-02 17:57:35 +0000 |
commit | 3e25e6e6b05c39b15deda65921d411ec8cb341ae (patch) | |
tree | 1b148b1597c6c63c5d2b987acac45032e8388edf /lib/sqlalchemy/orm/interfaces.py | |
parent | d578d67035c519d4205e757c926392896e6a57e7 (diff) | |
download | sqlalchemy-3e25e6e6b05c39b15deda65921d411ec8cb341ae.tar.gz |
- AttributeListener has been refined such that the event
is fired before the mutation actually occurs. Addtionally,
the append() and set() methods must now return the given value,
which is used as the value to be used in the mutation operation.
This allows creation of validating AttributeListeners which
raise before the action actually occurs, and which can change
the given value into something else before its used.
A new example "validate_attributes.py" shows one such recipe
for doing this. AttributeListener helper functions are
also on the way.
Diffstat (limited to 'lib/sqlalchemy/orm/interfaces.py')
-rw-r--r-- | lib/sqlalchemy/orm/interfaces.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py index 6dd2225c8..495d22be1 100644 --- a/lib/sqlalchemy/orm/interfaces.py +++ b/lib/sqlalchemy/orm/interfaces.py @@ -705,18 +705,35 @@ class AttributeExtension(object): """An event handler for individual attribute change events. AttributeExtension is assembled within the descriptors associated - with a mapped class. + with a mapped class. """ def append(self, state, value, initiator): - pass + """Receive a collection append event. + + The returned value will be used as the actual value to be + appended. + + """ + return value def remove(self, state, value, initiator): + """Receive a remove event. + + No return value is defined. + + """ pass def set(self, state, value, oldvalue, initiator): - pass + """Receive a set event. + + The returned value will be used as the actual value to be + set. + + """ + return value class StrategizedOption(PropertyOption): |