Skip to content

Commit

Permalink
add data_pub messages
Browse files Browse the repository at this point in the history
for publishing raw data, rather than reprs (zmq-only)
  • Loading branch information
minrk committed Aug 1, 2012
1 parent 14006db commit 3a7e432
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions IPython/core/interactiveshell.py
Expand Up @@ -270,6 +270,7 @@ class InteractiveShell(SingletonConfigurable):
display_formatter = Instance(DisplayFormatter)
displayhook_class = Type(DisplayHook)
display_pub_class = Type(DisplayPublisher)
data_pub_class = None

exit_now = CBool(False)
exiter = Instance(ExitAutocall)
Expand Down Expand Up @@ -483,6 +484,7 @@ def __init__(self, config=None, ipython_dir=None, profile_dir=None,
self.init_prompts()
self.init_display_formatter()
self.init_display_pub()
self.init_data_pub()
self.init_displayhook()
self.init_reload_doctest()
self.init_latextool()
Expand Down Expand Up @@ -659,6 +661,13 @@ def init_display_pub(self):
self.display_pub = self.display_pub_class(config=self.config)
self.configurables.append(self.display_pub)

def init_data_pub(self):
if not self.data_pub_class:
self.data_pub = None
return
self.data_pub = self.data_pub_class(config=self.config)
self.configurables.append(self.data_pub)

def init_displayhook(self):
# Initialize displayhook, set in/out prompts and printing system
self.displayhook = self.displayhook_class(
Expand Down
4 changes: 4 additions & 0 deletions IPython/zmq/ipkernel.py
Expand Up @@ -147,6 +147,8 @@ def __init__(self, **kwargs):
self.shell.displayhook.topic = self._topic('pyout')
self.shell.display_pub.session = self.session
self.shell.display_pub.pub_socket = self.iopub_socket
self.shell.data_pub.session = self.session
self.shell.data_pub.pub_socket = self.iopub_socket

# TMP - hack while developing
self.shell._reply_content = None
Expand Down Expand Up @@ -353,6 +355,7 @@ def execute_request(self, stream, ident, parent):
# Set the parent message of the display hook and out streams.
shell.displayhook.set_parent(parent)
shell.display_pub.set_parent(parent)
shell.data_pub.set_parent(parent)
sys.stdout.set_parent(parent)
sys.stderr.set_parent(parent)

Expand Down Expand Up @@ -538,6 +541,7 @@ def apply_request(self, stream, ident, parent):
shell = self.shell
shell.displayhook.set_parent(parent)
shell.display_pub.set_parent(parent)
shell.data_pub.set_parent(parent)
sys.stdout.set_parent(parent)
sys.stderr.set_parent(parent)

Expand Down
2 changes: 2 additions & 0 deletions IPython/zmq/zmqshell.py
Expand Up @@ -44,6 +44,7 @@
from IPython.utils.traitlets import Instance, Type, Dict, CBool, CBytes
from IPython.utils.warn import warn, error
from IPython.zmq.displayhook import ZMQShellDisplayHook
from IPython.zmq.datapub import ZMQDataPublisher
from IPython.zmq.session import extract_header
from session import Session

Expand Down Expand Up @@ -464,6 +465,7 @@ class ZMQInteractiveShell(InteractiveShell):

displayhook_class = Type(ZMQShellDisplayHook)
display_pub_class = Type(ZMQDisplayPublisher)
data_pub_class = Type(ZMQDataPublisher)

# 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
Expand Down

0 comments on commit 3a7e432

Please sign in to comment.