From e817bfdaeb24d9281e71e4ac05212ef3a9a3ca06 Mon Sep 17 00:00:00 2001 From: Brian Granger Date: Thu, 31 May 2012 12:28:27 -0700 Subject: [PATCH] Update directview.ipynb & allowing no-callbacks in kernel.execute. --- .../html/notebook/static/js/kernel.js | 5 +++-- .../widgets/directview/directview.ipynb | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/IPython/frontend/html/notebook/static/js/kernel.js b/IPython/frontend/html/notebook/static/js/kernel.js index 0d05fc07d..04a2218e5 100644 --- a/IPython/frontend/html/notebook/static/js/kernel.js +++ b/IPython/frontend/html/notebook/static/js/kernel.js @@ -262,6 +262,7 @@ var IPython = (function (IPython) { // complete_reply message documented here: // // http://ipython.org/ipython-doc/dev/development/messaging.html#complete + callbacks = callbacks || {}; var content = { text : '', line : line, @@ -303,7 +304,7 @@ var IPython = (function (IPython) { Kernel.prototype.set_callbacks_for_msg = function (msg_id, callbacks) { - this._msg_callbacks[msg_id] = callbacks; + this._msg_callbacks[msg_id] = callbacks || {}; } @@ -320,7 +321,7 @@ var IPython = (function (IPython) { } }; - if (content.payload !== undefined) { + if (content.payload !== undefined && callbacks.cell !== undefined) { var payload = content.payload || []; this._handle_payload(callbacks.cell, payload); } diff --git a/docs/examples/widgets/directview/directview.ipynb b/docs/examples/widgets/directview/directview.ipynb index e4145f4bf..fcd58ec2b 100644 --- a/docs/examples/widgets/directview/directview.ipynb +++ b/docs/examples/widgets/directview/directview.ipynb @@ -9,7 +9,25 @@ { "cell_type": "code", "input": [ - "" + "from directview import interact", + "from IPython.parallel import Client" + ], + "language": "python", + "outputs": [] + }, + { + "cell_type": "code", + "input": [ + "c = Client()", + "dv = c[:]" + ], + "language": "python", + "outputs": [] + }, + { + "cell_type": "code", + "input": [ + "interact(dv)" ], "language": "python", "outputs": []