From 87f6504ecb0189e74e90c57d2ef8b2e49a5ffe18 2014-11-03 18:17:12 From: Jeff Hemmelgarn Date: 2014-11-03 18:17:12 Subject: [PATCH] Move saving to contentmanager Make notebook.save_notebook call contentmanager.save_notebook. --- diff --git a/IPython/html/static/base/js/contentmanager.js b/IPython/html/static/base/js/contentmanager.js index a784beb..49fc9a4 100644 --- a/IPython/html/static/base/js/contentmanager.js +++ b/IPython/html/static/base/js/contentmanager.js @@ -118,6 +118,7 @@ define([ }; ContentManager.prototype.save_notebook = function(notebook, extra_settings) { + var that = notebook; // Create a JSON model to be sent to the server. var model = {}; model.name = notebook.notebook_name; @@ -134,8 +135,8 @@ define([ type : "PUT", data : JSON.stringify(model), contentType: 'application/json', - success : $.proxy(notebook.save_notebook_success, this, start), - error : $.proxy(notebook.save_notebook_error, this) + success : $.proxy(notebook.save_notebook_success, that, start), + error : $.proxy(notebook.save_notebook_error, that) }; if (extra_settings) { for (var key in extra_settings) { diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 6044a4d..0f3fc3b 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -1904,41 +1904,7 @@ define([ * @method save_notebook */ Notebook.prototype.save_notebook = function (extra_settings) { - // Create a JSON model to be sent to the server. - var model = {}; - model.name = this.notebook_name; - model.path = this.notebook_path; - model.type = 'notebook'; - model.format = 'json'; - model.content = this.toJSON(); - model.content.nbformat = this.nbformat; - model.content.nbformat_minor = this.nbformat_minor; - // time the ajax call for autosave tuning purposes. - var start = new Date().getTime(); - // We do the call with settings so we can set cache to false. - var settings = { - processData : false, - cache : false, - type : "PUT", - data : JSON.stringify(model), - contentType: 'application/json', - dataType : "json", - success : $.proxy(this.save_notebook_success, this, start), - error : $.proxy(this.save_notebook_error, this) - }; - if (extra_settings) { - for (var key in extra_settings) { - settings[key] = extra_settings[key]; - } - } - this.events.trigger('notebook_saving.Notebook'); - var url = utils.url_join_encode( - this.base_url, - 'api/contents', - this.notebook_path, - this.notebook_name - ); - $.ajax(url, settings); + this.content_manager.save_notebook(this, extra_settings); }; /**