summaryrefslogtreecommitdiff
path: root/alot/commands/__init__.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-08-19 00:38:04 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2012-08-19 20:39:17 +0100
commit6620ab381834018a65c66bf3dd9ab4b6d4527487 (patch)
treede9da8f46d22c694f666cf7bf939e8e14855ca59 /alot/commands/__init__.py
parent0fd350cc95d0f55d8968b785977abfd1b7b6fb11 (diff)
Pre/Posthooks are no longer Command.__init__ parms
but are directly set to cmd.pre/posthook by commandfactory. This still means that these hooks are looked up and stored *in* the cmd obj in the factory: so whenever FooCommand is instanciated from within some other commands apply, the hooks are None.
Diffstat (limited to 'alot/commands/__init__.py')
-rw-r--r--alot/commands/__init__.py27
1 files changed, 11 insertions, 16 deletions
diff --git a/alot/commands/__init__.py b/alot/commands/__init__.py
index d3a052d0..2fd61b84 100644
--- a/alot/commands/__init__.py
+++ b/alot/commands/__init__.py
@@ -14,17 +14,9 @@ from alot.helper import split_commandstring
class Command(object):
"""base class for commands"""
- def __init__(self, prehook=None, posthook=None):
- """
- :param prehook: name of the hook to call directly before
- applying this command
- :type prehook: str
- :param posthook: name of the hook to call directly after
- applying this command
- :type posthook: str
- """
- self.prehook = prehook
- self.posthook = posthook
+ def __init__(self):
+ self.prehook = None
+ self.posthook = None
self.undoable = False
self.help = self.__doc__
@@ -191,17 +183,20 @@ def commandfactory(cmdline, mode='global'):
parms = vars(parser.parse_args(args))
parms.update(forcedparms)
- logging.debug('PARMS: %s' % parms)
+
+ logging.debug('cmd parms %s' % parms)
+
+ # create Command
+ cmd = cmdclass(**parms)
# set pre and post command hooks
get_hook = settings.get_hook
- parms['prehook'] = get_hook('pre_%s_%s' % (mode, cmdname)) or \
+ cmd.prehook = get_hook('pre_%s_%s' % (mode, cmdname)) or \
get_hook('pre_global_%s' % cmdname)
- parms['posthook'] = get_hook('post_%s_%s' % (mode, cmdname)) or \
+ cmd.posthook = get_hook('post_%s_%s' % (mode, cmdname)) or \
get_hook('post_global_%s' % cmdname)
- logging.debug('cmd parms %s' % parms)
- return cmdclass(**parms)
+ return cmd
pyfiles = glob.glob1(os.path.dirname(__file__), '*.py')