diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-07-24 18:52:47 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-07-24 18:52:47 -0400 |
commit | 5f7d70124ed6999e25bfaba948738a99bae2044e (patch) | |
tree | 15ecb7f88ef7401738ef56121145721715e9e15c /lib/sqlalchemy/event.py | |
parent | 693e2dcacf7c6317c131ad11fcc0466e6c9164b8 (diff) | |
download | sqlalchemy-5f7d70124ed6999e25bfaba948738a99bae2044e.tar.gz |
shoulda listened harder in APL class
Diffstat (limited to 'lib/sqlalchemy/event.py')
-rw-r--r-- | lib/sqlalchemy/event.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/sqlalchemy/event.py b/lib/sqlalchemy/event.py index f844b3345..5fcda0a65 100644 --- a/lib/sqlalchemy/event.py +++ b/lib/sqlalchemy/event.py @@ -33,13 +33,27 @@ class Events(object): class _ExecEvent(object): def exec_and_clear(self, *args, **kw): - """Execute the given event once, then clear all listeners.""" + """Execute this event once, then clear all listeners.""" self(*args, **kw) self[:] = [] + + def exec_until_return(self, *args, **kw): + """Execute listeners for this event until + one returns a non-None value. + + Returns the value, or None. + """ + + if self: + for fn in self: + r = fn(*args, **kw) + if r is not None: + return r + return None def __call__(self, *args, **kw): - """Execute the given event.""" + """Execute this event.""" if self: for fn in self: |