Fixed bug when linking kernel to new code cells

pull/37/head
Zachary Sailer 13 years ago committed by MinRK
parent c4e06a3728
commit bfff3d817d

@ -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

@ -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;
}
/**

@ -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<ncells; i++) {
var cell = this.get_cell(i);
if (cell instanceof IPython.CodeCell) {
cell.set_session(this.session);
};
};
};
/**
* Prompt the user to restart the IPython kernel.
*

@ -68,15 +68,7 @@ var IPython = (function (IPython) {
var base_url = $('body').data('baseKernelUrl') + "api/kernels";
this.kernel = new IPython.Kernel(base_url, this.session_id);
// Now that the kernel has been created, tell the CodeCells about it.
this.kernel._kernel_started(this.kernel_content)
var ncells = this.notebook.ncells();
for (var i=0; i<ncells; i++) {
var cell = this.notebook.get_cell(i);
if (cell instanceof IPython.CodeCell) {
cell.set_kernel(this.kernel)
};
};
this.kernel._kernel_started(this.kernel_content);
};
/**

Loading…
Cancel
Save