From 5bd8c192c7185dce669d730dbba19fecf267d29a 2013-10-23 02:44:47 From: MinRK Date: 2013-10-23 02:44:47 Subject: [PATCH] make parent_header available from the Shell object --- diff --git a/IPython/kernel/zmq/ipkernel.py b/IPython/kernel/zmq/ipkernel.py index d7f0a95..f5951e9 100755 --- a/IPython/kernel/zmq/ipkernel.py +++ b/IPython/kernel/zmq/ipkernel.py @@ -1,14 +1,5 @@ #!/usr/bin/env python -"""A simple interactive kernel that talks to a frontend over 0MQ. - -Things to do: - -* Implement `set_parent` logic. Right before doing exec, the Kernel should - call set_parent on all the PUB objects with the message about to be executed. -* Implement random port and security key logic. -* Implement control messages. -* Implement event loop and poll version. -""" +"""An interactive kernel that talks to frontends over 0MQ.""" #----------------------------------------------------------------------------- # Imports diff --git a/IPython/kernel/zmq/zmqshell.py b/IPython/kernel/zmq/zmqshell.py index 8286a74..8812994 100644 --- a/IPython/kernel/zmq/zmqshell.py +++ b/IPython/kernel/zmq/zmqshell.py @@ -478,6 +478,7 @@ class ZMQInteractiveShell(InteractiveShell): display_pub_class = Type(ZMQDisplayPublisher) data_pub_class = Type(ZMQDataPublisher) kernel = Any() + parent_header = Any() # Override the traitlet in the parent class, because there's no point using # readline for the kernel. Can be removed when the readline code is moved @@ -589,6 +590,7 @@ class ZMQInteractiveShell(InteractiveShell): def set_parent(self, parent): """Set the parent header for associating output with its triggering input""" + self.parent_header = parent self.displayhook.set_parent(parent) self.display_pub.set_parent(parent) self.data_pub.set_parent(parent) @@ -601,6 +603,9 @@ class ZMQInteractiveShell(InteractiveShell): except AttributeError: pass + def get_parent(self): + return self.parent_header + #------------------------------------------------------------------------- # Things related to magics #-------------------------------------------------------------------------