diff --git a/IPython/html/static/notebook/js/comm.js b/IPython/html/static/notebook/js/comm.js
index 38fafa8..95da4b0 100644
--- a/IPython/html/static/notebook/js/comm.js
+++ b/IPython/html/static/notebook/js/comm.js
@@ -24,7 +24,7 @@ var IPython = (function (IPython) {
var CommManager = function (kernel) {
this.comms = {};
- this.targets = {comm : Comm};
+ this.targets = {};
if (kernel !== undefined) {
this.init_kernel(kernel);
}
@@ -40,9 +40,9 @@ var IPython = (function (IPython) {
}
};
- CommManager.prototype.register_target = function (target, constructor) {
- // Register a constructor for a given target key
- this.targets[target] = constructor;
+ CommManager.prototype.register_target = function (target_name, f) {
+ // Register a target function for a given target name
+ this.targets[target_name] = f;
};
CommManager.prototype.register_comm = function (comm) {
@@ -61,9 +61,9 @@ var IPython = (function (IPython) {
CommManager.prototype.comm_open = function (msg) {
var content = msg.content;
- var callback = this.targets[content.target];
+ var callback = this.targets[content.target_name];
if (callback === undefined) {
- console.log("No such target registered: ", content.target);
+ console.log("No such target registered: ", content.target_name);
console.log("Available targets are: ", this.targets);
return;
}
@@ -96,9 +96,9 @@ var IPython = (function (IPython) {
// Comm base class
//-----------------------------------------------------------------------
- var Comm = function (comm_id, target) {
+ var Comm = function (comm_id, target_name) {
this.comm_id = comm_id || new IPython.utils.uuid();
- this.target = target || 'comm';
+ this.target_name = target_name;
this._msg_callback = this._open_callback = this._close_callback = null;
};
@@ -106,7 +106,7 @@ var IPython = (function (IPython) {
Comm.prototype.open = function (data, callbacks) {
var content = {
comm_id : this.comm_id,
- target : this.target,
+ target_name : this.target_name,
data : data || {},
};
return this.kernel.send_shell_message("comm_open", content, callbacks);
diff --git a/IPython/kernel/comm/comm.py b/IPython/kernel/comm/comm.py
index 7a10cb8..1e94c3a 100644
--- a/IPython/kernel/comm/comm.py
+++ b/IPython/kernel/comm/comm.py
@@ -37,7 +37,7 @@ class Comm(LoggingConfigurable):
return
return self.shell.kernel.session
- target = Unicode('comm')
+ target_name = Unicode('comm')
topic = Bytes()
def _topic_default(self):
@@ -82,7 +82,7 @@ class Comm(LoggingConfigurable):
"""Open the frontend-side version of this comm"""
if data is None:
data = self._open_data
- self._publish_msg('comm_open', data, target=self.target)
+ self._publish_msg('comm_open', data, target_name=self.target_name)
def close(self, data=None):
"""Close the frontend-side version of this comm"""
diff --git a/IPython/kernel/comm/manager.py b/IPython/kernel/comm/manager.py
index f7d3a56..75e24a7 100644
--- a/IPython/kernel/comm/manager.py
+++ b/IPython/kernel/comm/manager.py
@@ -76,8 +76,8 @@ class CommManager(LoggingConfigurable):
# Public APIs
- def register_target(self, target, f):
- """Register a callable f for a given target
+ def register_target(self, target_name, f):
+ """Register a callable f for a given target name
f will be called with a Comm object as its only argument
when a comm_open message is received with `target`.
@@ -87,7 +87,7 @@ class CommManager(LoggingConfigurable):
if isinstance(f, basestring):
f = import_item(f)
- self.targets[target] = f
+ self.targets[target_name] = f
def register_comm(self, comm):
"""Register a new comm"""
@@ -125,18 +125,18 @@ class CommManager(LoggingConfigurable):
"""Handler for comm_open messages"""
content = msg['content']
comm_id = content['comm_id']
- target = content['target']
- callback = self.targets.get(target, None)
+ target_name = content['target_name']
+ f = self.targets.get(target_name, None)
comm = Comm(comm_id=comm_id,
shell=self.shell,
iopub_socket=self.iopub_socket,
primary=False,
)
- if callback is None:
- self.log.error("No such comm target registered: %s", target)
+ if f is None:
+ self.log.error("No such comm target registered: %s", target_name)
comm.close()
return
- callback(comm)
+ f(comm)
comm.handle_open(msg)
self.register_comm(comm)