From 60600c308ad91b78a41815a93d1f01405b5f56f9 2014-07-22 22:24:20 From: MinRK Date: 2014-07-22 22:24:20 Subject: [PATCH] pass ws_url to kernel constructor via session constructor via notebook constructor… --- diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 8586eb6..32b9bdb 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -59,6 +59,7 @@ define([ this.keyboard_manager = options.keyboard_manager; this.save_widget = options.save_widget; this.tooltip = new tooltip.Tooltip(this.events); + this.ws_url = options.ws_url; // default_kernel_name is a temporary measure while we implement proper // kernel selection and delayed start. Do not rely on it. this.default_kernel_name = 'python'; @@ -1496,6 +1497,7 @@ define([ Notebook.prototype.start_session = function () { this.session = new session.Session({ base_url: this.base_url, + ws_url: this.ws_url, notebook_path: this.notebook_path, notebook_name: this.notebook_name, // For now, create all sessions with the 'python' kernel, which is the diff --git a/IPython/html/static/services/kernels/js/kernel.js b/IPython/html/static/services/kernels/js/kernel.js index 1506cd7..b18d16d 100644 --- a/IPython/html/static/services/kernels/js/kernel.js +++ b/IPython/html/static/services/kernels/js/kernel.js @@ -15,7 +15,7 @@ define([ * A Kernel Class to communicate with the Python kernel * @Class Kernel */ - var Kernel = function (kernel_service_url, notebook, name) { + var Kernel = function (kernel_service_url, ws_url, notebook, name) { this.events = notebook.events; this.kernel_id = null; this.shell_channel = null; @@ -23,7 +23,7 @@ define([ this.stdin_channel = null; this.kernel_service_url = kernel_service_url; this.name = name; - this.ws_url = IPython.utils.get_body_data("wsUrl"); + this.ws_url = ws_url || IPython.utils.get_body_data("wsUrl"); if (!this.ws_url) { // trailing 's' in https will become wss for secure web sockets this.ws_url = location.protocol.replace('http', 'ws') + "//" + location.host; diff --git a/IPython/html/static/services/sessions/js/session.js b/IPython/html/static/services/sessions/js/session.js index 2283c85..34c6996 100644 --- a/IPython/html/static/services/sessions/js/session.js +++ b/IPython/html/static/services/sessions/js/session.js @@ -17,6 +17,7 @@ define([ this.path = options.notebook_path; this.kernel_name = options.kernel_name; this.base_url = options.base_url; + this.ws_url = options.ws_url; }; Session.prototype.start = function(callback) { @@ -91,7 +92,7 @@ define([ Session.prototype._handle_start_success = function (data, status, xhr) { this.id = data.id; var kernel_service_url = utils.url_path_join(this.base_url, "api/kernels"); - this.kernel = new kernel.Kernel(kernel_service_url, this.notebook, this.kernel_name); + this.kernel = new kernel.Kernel(kernel_service_url, this.ws_url, this.notebook, this.kernel_name); this.kernel._kernel_started(data.kernel); };