+
+ Another important attribute is :attr:`command_stack`, which holds
+ a :class:`~hooke.command_stack.CommandStack` listing the commands
+ that have been applied to the `Curve` since loading.
+
+ The data-type is pickleable, to ensure we can move it between
+ processes with :class:`multiprocessing.Queue`\s.
+
+ >>> import pickle
+ >>> import yaml
+ >>> from .engine import CommandMessage
+ >>> c = Curve(path='some/path')
+
+ We add a recursive reference to `c` as you would get from
+ :meth:`hooke.plugin.curve.CurveCommand._add_to_command_stack`.
+
+ >>> c.command_stack.append(CommandMessage('curve info', {'curve':c}))
+
+ >>> s = pickle.dumps(c)
+ >>> z = pickle.loads(s)
+ >>> z
+ <Curve path>
+ >>> z.command_stack
+ [<CommandMessage curve info {curve: <Curve path>}>]
+ >>> z.command_stack[-1].arguments['curve'] == z
+ True
+ >>> print yaml.dump(c) # doctest: +REPORT_UDIFF
+ &id001 !!python/object:hooke.curve.Curve
+ command_stack: !!python/object/new:hooke.command_stack.CommandStack
+ listitems:
+ - !!python/object:hooke.engine.CommandMessage
+ arguments:
+ curve: *id001
+ command: curve info
+ name: path
+ path: some/path
+ <BLANKLINE>
+
+ However, if we try and serialize the command stack first, we run
+ into `Python issue 1062277`_.
+
+ .. _Python issue 1062277: http://bugs.python.org/issue1062277
+
+ >>> pickle.dumps(c.command_stack)
+ Traceback (most recent call last):
+ ...
+ assert id(obj) not in self.memo
+ AssertionError
+
+ YAML still works, though.
+
+ >>> print yaml.dump(c.command_stack) # doctest: +REPORT_UDIFF
+ &id001 !!python/object/new:hooke.command_stack.CommandStack
+ listitems:
+ - !!python/object:hooke.engine.CommandMessage
+ arguments:
+ curve: !!python/object:hooke.curve.Curve
+ command_stack: *id001
+ name: path
+ path: some/path
+ command: curve info
+ <BLANKLINE>