From 38e347a79f3c93a93ee767063f2fedc8c65a5965 2013-10-17 21:07:51 From: Zachary Sailer Date: 2013-10-17 21:07:51 Subject: [PATCH] Fixed bug when linking kernel to new code cells --- diff --git a/IPython/html/services/notebooks/handlers.py b/IPython/html/services/notebooks/handlers.py index 3be4d23..8ab6a2c 100644 --- a/IPython/html/services/notebooks/handlers.py +++ b/IPython/html/services/notebooks/handlers.py @@ -87,7 +87,6 @@ class NotebookHandler(IPythonHandler): notebook_name, notebook_path = nbm.named_notebook_path(notebook_path) data = jsonapi.loads(self.request.body) model = nbm.change_notebook(data, notebook_name, notebook_path) - self.log.info(model) self.finish(jsonapi.dumps(model)) @web.authenticated diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index 32ea289..de9fa14 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -60,8 +60,8 @@ var IPython = (function (IPython) { * @param {object|undefined} [options] * @param [options.cm_config] {object} config to pass to CodeMirror */ - var CodeCell = function (kernel, options) { - this.kernel = kernel || null; + var CodeCell = function (session, options) { + this.session = session || null; this.code_mirror = null; this.input_prompt_number = null; this.collapsed = false; @@ -232,8 +232,8 @@ var IPython = (function (IPython) { // Kernel related calls. - CodeCell.prototype.set_kernel = function (kernel) { - this.kernel = kernel; + CodeCell.prototype.set_session = function (session) { + this.session = session; } /** diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index e169b04..6dfb51f 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -374,7 +374,7 @@ var IPython = (function (IPython) { // TODO: Make killing the kernel configurable. var kill_kernel = false; if (kill_kernel) { - that.kernel.kill(); + that.session.kill_kernel(); } // if we are autosaving, trigger an autosave on nav-away. // still warn, because if we don't the autosave may fail. @@ -798,7 +798,7 @@ var IPython = (function (IPython) { if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) { if (type === 'code') { - cell = new IPython.CodeCell(this.kernel); + cell = new IPython.CodeCell(this.session); cell.set_input_prompt(); } else if (type === 'markdown') { cell = new IPython.MarkdownCell(); @@ -1393,8 +1393,24 @@ var IPython = (function (IPython) { var notebook_info = this.notebookPath() + this.notebook_name; this.session = new IPython.Session(notebook_info, this); this.session.start(); + this.link_cells_to_session(); }; + + /** + * Once a session is started, link the code cells to the session + * + */ + Notebook.prototype.link_cells_to_session= function(){ + var ncells = this.ncells(); + for (var i=0; i