diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2013-08-06 19:56:26 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2013-10-30 20:56:39 +0000 |
commit | fc0a508350074eae0ea47a520659d43a05451111 (patch) | |
tree | 26e20bd0c92f16b10b86c67b0a7ebc4e3a31723a /alot/ui.py | |
parent | 3984560711d12e7f750d6ee54e9f129c6d4a6c1e (diff) |
hand Command instance to pre/post hooks
When a pre or post command hook is called it gets
the Command instance it belongs to as keyword parameter "cmd".
This allows e.g. the post hook of TagCommands to access the
query string used in this particular instance.
Diffstat (limited to 'alot/ui.py')
-rw-r--r-- | alot/ui.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -617,8 +617,10 @@ class UI(object): def call_posthook(retval_from_apply): if cmd.posthook: logging.info('calling post-hook') - return defer.maybeDeferred(cmd.posthook, ui=self, - dbm=self.dbman) + return defer.maybeDeferred(cmd.posthook, + ui=self, + dbm=self.dbman, + cmd=cmd) # define a generic error handler for Failures/Exceptions # raised in cmd.apply() @@ -638,7 +640,7 @@ class UI(object): return defer.maybeDeferred(cmd.apply, self) prehook = cmd.prehook or (lambda **kwargs: None) - d = defer.maybeDeferred(prehook, ui=self, dbm=self.dbman) + d = defer.maybeDeferred(prehook, ui=self, dbm=self.dbman, cmd=cmd) d.addCallback(call_apply) d.addCallback(call_posthook) if handle_error: |