diff --git a/IPython/html/static/notebook/js/comm.js b/IPython/html/static/notebook/js/comm.js index 95da4b0..3633b74 100644 --- a/IPython/html/static/notebook/js/comm.js +++ b/IPython/html/static/notebook/js/comm.js @@ -61,16 +61,15 @@ var IPython = (function (IPython) { CommManager.prototype.comm_open = function (msg) { var content = msg.content; - var callback = this.targets[content.target_name]; - if (callback === undefined) { + var f = this.targets[content.target_name]; + if (f === undefined) { console.log("No such target registered: ", content.target_name); console.log("Available targets are: ", this.targets); return; } var comm = new Comm(content.comm_id); this.register_comm(comm); - callback(comm); - comm.handle_open(msg); + f(comm, msg); }; CommManager.prototype.comm_close = function (msg) { @@ -99,7 +98,7 @@ var IPython = (function (IPython) { var Comm = function (comm_id, target_name) { this.comm_id = comm_id || new IPython.utils.uuid(); this.target_name = target_name; - this._msg_callback = this._open_callback = this._close_callback = null; + this._msg_callback = this._close_callback = null; }; // methods for sending messages @@ -133,10 +132,6 @@ var IPython = (function (IPython) { this['_' + key + '_callback'] = callback; }; - Comm.prototype.on_open = function (callback) { - this._register_callback('open', callback); - }; - Comm.prototype.on_msg = function (callback) { this._register_callback('msg', callback); }; @@ -152,10 +147,6 @@ var IPython = (function (IPython) { if (callback) callback(msg); }; - Comm.prototype.handle_open = function (msg) { - this._maybe_callback('open', msg); - }; - Comm.prototype.handle_msg = function (msg) { this._maybe_callback('msg', msg); }; diff --git a/IPython/kernel/comm/comm.py b/IPython/kernel/comm/comm.py index 1e94c3a..16a7d61 100644 --- a/IPython/kernel/comm/comm.py +++ b/IPython/kernel/comm/comm.py @@ -43,10 +43,9 @@ class Comm(LoggingConfigurable): def _topic_default(self): return ('comm-%s' % self.comm_id).encode('ascii') - _open_data = Dict(help="data dict, if any, to be included in comm_close") + _open_data = Dict(help="data dict, if any, to be included in comm_open") _close_data = Dict(help="data dict, if any, to be included in comm_close") - _open_callback = Any() _msg_callback = Any() _close_callback = Any() @@ -61,7 +60,7 @@ class Comm(LoggingConfigurable): super(Comm, self).__init__(**kwargs) get_ipython().comm_manager.register_comm(self) if self.primary: - # I am primary, open my peer + # I am primary, open my peer. self.open(data) def _publish_msg(self, msg_type, data=None, **keys): @@ -99,14 +98,6 @@ class Comm(LoggingConfigurable): self._publish_msg('comm_msg', data) # registering callbacks - def on_open(self, callback): - """Register a callback for comm_open - - Will be called with the `data` of the open message. - - Call `on_open(None)` to disable an existing callback. - """ - self._open_callback = callback def on_close(self, callback): """Register a callback for comm_close @@ -128,12 +119,6 @@ class Comm(LoggingConfigurable): # handling of incoming messages - def handle_open(self, msg): - """Handle a comm_open message""" - self.log.debug("handle_open[%s](%s)", self.comm_id, msg) - if self._open_callback: - self._open_callback(msg) - def handle_close(self, msg): """Handle a comm_close message""" self.log.debug("handle_close[%s](%s)", self.comm_id, msg) diff --git a/IPython/kernel/comm/manager.py b/IPython/kernel/comm/manager.py index 75e24a7..315209f 100644 --- a/IPython/kernel/comm/manager.py +++ b/IPython/kernel/comm/manager.py @@ -136,9 +136,8 @@ class CommManager(LoggingConfigurable): self.log.error("No such comm target registered: %s", target_name) comm.close() return - f(comm) - comm.handle_open(msg) self.register_comm(comm) + f(comm, msg) @with_output def comm_msg(self, stream, ident, msg):