From 6845b777baaf1d79664fe706eac35fbeb3ddab39 2013-10-17 21:09:12 From: Zachary Sailer Date: 2013-10-17 21:09:12 Subject: [PATCH] Fixed session js ajax request. Session was not creating a kernel object on the client side, after the server created successfully created a session. --- diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index de9fa14..d168333 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -66,7 +66,6 @@ var IPython = (function (IPython) { this.input_prompt_number = null; this.collapsed = false; this.cell_type = "code"; - this.last_msg_id = null; var cm_overwrite_options = { @@ -241,12 +240,9 @@ var IPython = (function (IPython) { * @method execute */ CodeCell.prototype.execute = function () { - this.output_area.clear_output(); + this.output_area.clear_output(true, true, true); this.set_input_prompt('*'); this.element.addClass("running"); - if (this.last_msg_id) { - this.kernel.clear_callbacks_for_msg(this.last_msg_id); - } var callbacks = { 'execute_reply': $.proxy(this._handle_execute_reply, this), 'output': $.proxy(this.output_area.handle_output, this.output_area), @@ -254,7 +250,7 @@ var IPython = (function (IPython) { 'set_next_input': $.proxy(this._handle_set_next_input, this), 'input_request': $.proxy(this._handle_input_request, this) }; - this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true}); + var msg_id = this.session.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true}); }; /** @@ -390,8 +386,8 @@ var IPython = (function (IPython) { }; - CodeCell.prototype.clear_output = function (wait) { - this.output_area.clear_output(wait); + CodeCell.prototype.clear_output = function (stdout, stderr, other) { + this.output_area.clear_output(stdout, stderr, other); }; @@ -442,4 +438,4 @@ var IPython = (function (IPython) { IPython.CodeCell = CodeCell; return IPython; -}(IPython)); +}(IPython)); \ No newline at end of file diff --git a/IPython/html/static/services/sessions/js/session.js b/IPython/html/static/services/sessions/js/session.js index 8485719..9242007 100644 --- a/IPython/html/static/services/sessions/js/session.js +++ b/IPython/html/static/services/sessions/js/session.js @@ -13,31 +13,31 @@ var IPython = (function (IPython) { var Session = function(notebook_name, notebook_path, Notebook){ this.kernel = null; - this.kernel_id = null; - this.session_id = null; - this.notebook_name = notebook_name; - this.notebook_path = notebook_path; + this.id = null; + this.name = notebook_name; + this.path = notebook_path; this.notebook = Notebook; this._baseProjectUrl = Notebook.baseProjectUrl() }; Session.prototype.start = function() { var that = this - var notebook = {'notebook':{'name': this.notebook_name, 'path': this.notebook_path}} + var notebook = {'notebook':{'name': this.name, 'path': this.path}} var settings = { processData : false, cache : false, type : "POST", data: JSON.stringify(notebook), dataType : "json", + success : $.proxy(this.start_kernel, that), }; var url = this._baseProjectUrl + 'api/sessions'; $.ajax(url, settings); }; Session.prototype.notebook_rename = function (name, path) { - this.notebook_name = name; - this.notebook_path = path; + this.name = name; + this.path = path; var notebook = {'notebook':{'name':name, 'path': path}}; var settings = { processData : false, @@ -68,7 +68,7 @@ var IPython = (function (IPython) { * @method start_kernel */ Session.prototype.start_kernel = function (json) { - this.session_id = json.id; + this.id = json.id; this.kernel_content = json.kernel; var base_url = $('body').data('baseKernelUrl') + "api/kernels"; this.kernel = new IPython.Kernel(base_url, this.session_id); diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index 4f82af9..c433f01 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -112,14 +112,15 @@ var IPython = (function (IPython) { NotebookList.prototype.sessions_loaded = function(data){ this.sessions = new Object(); + console.log(data) var len = data.length; if (len != 0) { for (var i=0; i