>>> c.append(CommandMessage(ca, {'param':'C'}))
>>> c.append(CommandMessage(cb, {'param':'D'}))
- Implement a dummy :meth:`_execute` for testing. This would
- usually call :meth:`hooke.command.Command.run` with appropriate
- arguments.
+ Implement a dummy :meth:`_execute` for testing.
- >>> def execute(command_message):
+ >>> def execute(hooke, command_message):
... cm = command_message
... print 'EXECUTE', cm.command.name, cm.arguments
>>> c._execute = execute
EXECUTE CommandB {'param': 'B'}
EXECUTE CommandB {'param': 'D'}
"""
- def execute(self, *args, **kwargs):
+ def execute(self, hooke):
"""Execute a stack of commands.
See Also
"""
for command_message in self:
if self.filter(command_message) == True:
- self._execute(command_message, *args, **kwargs)
+ self._execute(hooke, command_message)
def filter(self, command_message):
"""Any commands in the stack that are not subclasses of
"""
return True
- def _execute(self, command_message):
- raise NotImplementedError()
+ def _execute(self, hooke, command_message):
+ hooke.run_command(command_message.command, command_message.arguments)