diff --git a/IPython/html/services/contents/handlers.py b/IPython/html/services/contents/handlers.py
index aa02e18..a92d51b 100644
--- a/IPython/html/services/contents/handlers.py
+++ b/IPython/html/services/contents/handlers.py
@@ -205,9 +205,6 @@ class ContentsHandler(IPythonHandler):
self._copy(copy_from, path, name)
elif self.contents_manager.file_exists(name, path):
self._save(model, path, name)
- checkpoint = model.get('_checkpoint_after_save')
- if checkpoint:
- nbm.create_checkpoint(path, name)
else:
self._upload(model, path, name)
else:
diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js
index ad04f99..6671c0d 100644
--- a/IPython/html/static/notebook/js/notebook.js
+++ b/IPython/html/static/notebook/js/notebook.js
@@ -2357,18 +2357,13 @@ define([
* @method list_checkpoints
*/
Notebook.prototype.list_checkpoints = function () {
- var url = utils.url_join_encode(
- this.base_url,
- 'api/contents',
- this.notebook_path,
- this.notebook_name,
- 'checkpoints'
- );
- $.get(url).done(
- $.proxy(this.list_checkpoints_success, this)
- ).fail(
- $.proxy(this.list_checkpoints_error, this)
- );
+ var that = this;
+ this.contents.list_checkpoints(this.notebook_path, this.notebook_name, {
+ success_callback: $.proxy(this.list_checkpoints_success, this),
+ error_callback: function(xhr, status, error_msg) {
+ that.events.trigger('list_checkpoints_failed.Notebook');
+ }
+ });
};
/**
@@ -2391,35 +2386,18 @@ define([
};
/**
- * Failure callback for listing a checkpoint.
- *
- * @method list_checkpoint_error
- * @param {jqXHR} xhr jQuery Ajax object
- * @param {String} status Description of response status
- * @param {String} error_msg HTTP error message
- */
- Notebook.prototype.list_checkpoints_error = function (xhr, status, error_msg) {
- this.events.trigger('list_checkpoints_failed.Notebook');
- };
-
- /**
* Create a checkpoint of this notebook on the server from the most recent save.
*
* @method create_checkpoint
*/
Notebook.prototype.create_checkpoint = function () {
- var url = utils.url_join_encode(
- this.base_url,
- 'api/contents',
- this.notebook_path,
- this.notebook_name,
- 'checkpoints'
- );
- $.post(url).done(
- $.proxy(this.create_checkpoint_success, this)
- ).fail(
- $.proxy(this.create_checkpoint_error, this)
- );
+ var that = this;
+ this.contents.create_checkpoint(this.notebook_path, this.notebook_name, {
+ success_callback: $.proxy(this.create_checkpoint_success, this),
+ error_callback: function (xhr, status, error_msg) {
+ that.events.trigger('checkpoint_failed.Notebook');
+ }
+ });
};
/**
@@ -2436,18 +2414,6 @@ define([
this.events.trigger('checkpoint_created.Notebook', data);
};
- /**
- * Failure callback for creating a checkpoint.
- *
- * @method create_checkpoint_error
- * @param {jqXHR} xhr jQuery Ajax object
- * @param {String} status Description of response status
- * @param {String} error_msg HTTP error message
- */
- Notebook.prototype.create_checkpoint_error = function (xhr, status, error_msg) {
- this.events.trigger('checkpoint_failed.Notebook');
- };
-
Notebook.prototype.restore_checkpoint_dialog = function (checkpoint) {
var that = this;
checkpoint = checkpoint || this.last_checkpoint;
@@ -2497,19 +2463,14 @@ define([
*/
Notebook.prototype.restore_checkpoint = function (checkpoint) {
this.events.trigger('notebook_restoring.Notebook', checkpoint);
- var url = utils.url_join_encode(
- this.base_url,
- 'api/contents',
- this.notebook_path,
- this.notebook_name,
- 'checkpoints',
- checkpoint
- );
- $.post(url).done(
- $.proxy(this.restore_checkpoint_success, this)
- ).fail(
- $.proxy(this.restore_checkpoint_error, this)
- );
+ var that = this;
+ this.contents.restore_checkpoint(this.notebook_path, this.notebook_name,
+ checkpoint, {
+ success_callback: $.proxy(this.create_checkpoint_success, this),
+ error_callback: function (xhr, status, error_msg) {
+ that.events.trigger('checkpoint_restore_failed.Notebook');
+ }
+ });
};
/**
@@ -2526,18 +2487,6 @@ define([
};
/**
- * Failure callback for restoring a notebook to a checkpoint.
- *
- * @method restore_checkpoint_error
- * @param {jqXHR} xhr jQuery Ajax object
- * @param {String} status Description of response status
- * @param {String} error_msg HTTP error message
- */
- Notebook.prototype.restore_checkpoint_error = function (xhr, status, error_msg) {
- this.events.trigger('checkpoint_restore_failed.Notebook');
- };
-
- /**
* Delete a notebook checkpoint.
*
* @method delete_checkpoint
@@ -2545,18 +2494,13 @@ define([
*/
Notebook.prototype.delete_checkpoint = function (checkpoint) {
this.events.trigger('notebook_restoring.Notebook', checkpoint);
- var url = utils.url_join_encode(
- this.base_url,
- 'api/contents',
- this.notebook_path,
- this.notebook_name,
- 'checkpoints',
- checkpoint
- );
- $.ajax(url, {
- type: 'DELETE',
- success: $.proxy(this.delete_checkpoint_success, this),
- error: $.proxy(this.delete_checkpoint_error, this)
+ var that = this;
+ this.contents.delete_checkpoint(this.notebook_path, this.notebook_name,
+ checkpoint, {
+ success_callback: $.proxy(this.create_checkpoint_success, this),
+ error_callback: function (xhr, status, error_msg) {
+ that.events.trigger('checkpoint_delete_failed.Notebook', [xhr, status, error]);
+ }
});
};
@@ -2573,18 +2517,6 @@ define([
this.load_notebook(this.notebook_name, this.notebook_path);
};
- /**
- * Failure callback for deleting a notebook checkpoint.
- *
- * @method delete_checkpoint_error
- * @param {jqXHR} xhr jQuery Ajax object
- * @param {String} status Description of response status
- * @param {String} error HTTP error message
- */
- Notebook.prototype.delete_checkpoint_error = function (xhr, status, error) {
- this.events.trigger('checkpoint_delete_failed.Notebook', [xhr, status, error]);
- };
-
// For backwards compatability.
IPython.Notebook = Notebook;
diff --git a/IPython/html/static/services/contents.js b/IPython/html/static/services/contents.js
index dc8fd37..85f3e93 100644
--- a/IPython/html/static/services/contents.js
+++ b/IPython/html/static/services/contents.js
@@ -169,38 +169,44 @@ define([
* Checkpointing Functions
*/
- Contents.prototype.save_checkpoint = function() {
- // This is not necessary - integrated into save
+ Contents.prototype.create_checkpoint = function(path, name, options) {
+ var url = this.api_url(path, name, 'checkpoints');
+ var settings = {
+ type : "POST",
+ success: options.success_callback || function(data, status, xhr) {},
+ error: options.error_callback || function(xhr, status, error_msg) {}
+ };
+ $.ajax(url, settings);
};
- Contents.prototype.restore_checkpoint = function(notebook, id) {
- that = notebook;
- this.events.trigger('notebook_restoring.Notebook', checkpoint);
- var url = this.api_url(
- this.notebook_path,
- this.notebook_name,
- 'checkpoints',
- checkpoint
- );
- $.post(url).done(
- $.proxy(that.restore_checkpoint_success, that)
- ).fail(
- $.proxy(that.restore_checkpoint_error, that)
- );
+ Contents.prototype.list_checkpoints = function(path, name, options) {
+ var url = this.api_url(path, name, 'checkpoints');
+ var settings = {
+ type : "GET",
+ success: options.success_callback || function(data, status, xhr) {},
+ error: options.error_callback || function(xhr, status, error_msg) {}
+ };
+ $.ajax(url, settings);
};
- Contents.prototype.list_checkpoints = function(notebook) {
- that = notebook;
- var url = this.api_url(
- that.notebook_path,
- that.notebook_name,
- 'checkpoints'
- );
- $.get(url).done(
- $.proxy(that.list_checkpoints_success, that)
- ).fail(
- $.proxy(that.list_checkpoints_error, that)
- );
+ Contents.prototype.restore_checkpoint = function(path, name, checkpoint_id, options) {
+ var url = this.api_url(path, name, 'checkpoints', checkpoint_id);
+ var settings = {
+ type : "POST",
+ success: options.success_callback || function(data, status, xhr) {},
+ error: options.error_callback || function(xhr, status, error_msg) {}
+ };
+ $.ajax(url, settings);
+ };
+
+ Contents.prototype.delete_checkpoint = function(path, name, checkpoint_id, options) {
+ var url = this.api_url(path, name, 'checkpoints', checkpoint_id);
+ var settings = {
+ type : "DELETE",
+ success: options.success_callback || function(data, status, xhr) {},
+ error: options.error_callback || function(xhr, status, error_msg) {}
+ };
+ $.ajax(url, settings);
};
/**
@@ -225,7 +231,6 @@ define([
*/
Contents.prototype.list_contents = function(path, load_callback,
error_callback) {
- var that = this;
var settings = {
processData : false,
cache : false,