Added CurveEngine.run_command and reorganized CommandStack._execute
[hooke.git] / hooke / command_stack.py
index fc8dc751add0a9bece435ca37c27673ecbd853d0..3888a45e74efca10d1069b26833fecd6eff49fd3 100644 (file)
@@ -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)