diff --git a/IPython/html/static/widgets/js/widget_output.js b/IPython/html/static/widgets/js/widget_output.js
index 241841a..a9fa4c3 100644
--- a/IPython/html/static/widgets/js/widget_output.js
+++ b/IPython/html/static/widgets/js/widget_output.js
@@ -46,30 +46,14 @@ define([
/**
* Handles re-routed iopub messages.
*/
- _handle_route_msg: function(content) {
- if (content) {
- var msg_type = content.type;
- var json = {
- output_type: msg_type
- };
-
- var data = content.args[0];
+ _handle_route_msg: function(msg) {
+ if (msg) {
+ var msg_type = msg.msg_type;
if (msg_type=='clear_output') {
- this.output_area.clear_output(data.wait || false);
- return;
- } else if (msg_type === "stream") {
- data = content.kwargs.content;
- json.text = data.text;
- json.name = data.name;
- } else if (msg_type === "display_data") {
- json.data = data.data;
- json.metadata = data.metadata;
+ this.output_area.handle_clear_output(msg);
} else {
- console.log("unhandled output message", msg);
- return;
+ this.output_area.handle_output(msg);
}
-
- this.output_area.append_output(json);
}
},
});
diff --git a/IPython/html/widgets/widget_output.py b/IPython/html/widgets/widget_output.py
index 2ceb3a1..afa2021 100644
--- a/IPython/html/widgets/widget_output.py
+++ b/IPython/html/widgets/widget_output.py
@@ -46,12 +46,24 @@ class Output(DOMWidget):
self._original_send = send
self._session = session
- def send_hook(stream, msg_or_type, *args, **kwargs):
- if stream is kernel.iopub_socket and msg_or_type in ['clear_output', 'stream', 'display_data']:
- msg = {'type': msg_or_type, 'args': args, 'kwargs': kwargs}
- self.send(msg)
+ def send_hook(stream, msg_or_type, content=None, parent=None, ident=None,
+ buffers=None, track=False, header=None, metadata=None):
+
+ # Handle both prebuild messages and unbuilt messages.
+ if isinstance(msg_or_type, dict):
+ msg_type = msg_or_type['msg_type']
+ msg = msg_or_type
else:
- send(stream, msg_or_type, *args, **kwargs)
+ msg_type = msg_or_type
+ msg = session.msg(msg_type, content=content, parent=parent,
+ header=header, metadata=metadata)
+
+ # If this is a message type that we want to forward, forward it.
+ if stream is kernel.iopub_socket and msg_type in ['clear_output', 'stream', 'display_data']:
+ self.send(msg)
+ else:
+ send(stream, msg_or_type, content=content, parent=parent, ident=ident,
+ buffers=buffers, track=track, header=header, metadata=metadata)
session.send = send_hook