summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2013-08-06 19:56:26 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2013-10-30 20:56:39 +0000
commitfc0a508350074eae0ea47a520659d43a05451111 (patch)
tree26e20bd0c92f16b10b86c67b0a7ebc4e3a31723a /alot
parent3984560711d12e7f750d6ee54e9f129c6d4a6c1e (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')
-rw-r--r--alot/ui.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/alot/ui.py b/alot/ui.py
index 81b1a106..3f6a2ad4 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -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: