X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=hooke%2Fcommand_stack.py;fp=hooke%2Fcommand_stack.py;h=3888a45e74efca10d1069b26833fecd6eff49fd3;hp=fc8dc751add0a9bece435ca37c27673ecbd853d0;hb=608c372b4c9beb3f8c0cfc5a2889012827592d12;hpb=8e89eecbde44ef0be854d898455e8543a30204b7 diff --git a/hooke/command_stack.py b/hooke/command_stack.py index fc8dc75..3888a45 100644 --- a/hooke/command_stack.py +++ b/hooke/command_stack.py @@ -44,11 +44,9 @@ class CommandStack (list): >>> 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 @@ -74,7 +72,7 @@ class CommandStack (list): EXECUTE CommandB {'param': 'B'} EXECUTE CommandB {'param': 'D'} """ - def execute(self, *args, **kwargs): + def execute(self, hooke): """Execute a stack of commands. See Also @@ -83,7 +81,7 @@ class CommandStack (list): """ 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 @@ -91,5 +89,5 @@ class CommandStack (list): """ return True - def _execute(self, command_message): - raise NotImplementedError() + def _execute(self, hooke, command_message): + hooke.run_command(command_message.command, command_message.arguments)