Show More
@@ -205,9 +205,6 b' class ContentsHandler(IPythonHandler):' | |||
|
205 | 205 | self._copy(copy_from, path, name) |
|
206 | 206 | elif self.contents_manager.file_exists(name, path): |
|
207 | 207 | self._save(model, path, name) |
|
208 | checkpoint = model.get('_checkpoint_after_save') | |
|
209 | if checkpoint: | |
|
210 | nbm.create_checkpoint(path, name) | |
|
211 | 208 | else: |
|
212 | 209 | self._upload(model, path, name) |
|
213 | 210 | else: |
@@ -2357,18 +2357,13 b' define([' | |||
|
2357 | 2357 | * @method list_checkpoints |
|
2358 | 2358 | */ |
|
2359 | 2359 | Notebook.prototype.list_checkpoints = function () { |
|
2360 | var url = utils.url_join_encode( | |
|
2361 | this.base_url, | |
|
2362 | 'api/contents', | |
|
2363 | this.notebook_path, | |
|
2364 | this.notebook_name, | |
|
2365 |
|
|
|
2366 | ); | |
|
2367 | $.get(url).done( | |
|
2368 | $.proxy(this.list_checkpoints_success, this) | |
|
2369 | ).fail( | |
|
2370 | $.proxy(this.list_checkpoints_error, this) | |
|
2371 | ); | |
|
2360 | var that = this; | |
|
2361 | this.contents.list_checkpoints(this.notebook_path, this.notebook_name, { | |
|
2362 | success_callback: $.proxy(this.list_checkpoints_success, this), | |
|
2363 | error_callback: function(xhr, status, error_msg) { | |
|
2364 | that.events.trigger('list_checkpoints_failed.Notebook'); | |
|
2365 | } | |
|
2366 | }); | |
|
2372 | 2367 | }; |
|
2373 | 2368 | |
|
2374 | 2369 | /** |
@@ -2391,35 +2386,18 b' define([' | |||
|
2391 | 2386 | }; |
|
2392 | 2387 | |
|
2393 | 2388 | /** |
|
2394 | * Failure callback for listing a checkpoint. | |
|
2395 | * | |
|
2396 | * @method list_checkpoint_error | |
|
2397 | * @param {jqXHR} xhr jQuery Ajax object | |
|
2398 | * @param {String} status Description of response status | |
|
2399 | * @param {String} error_msg HTTP error message | |
|
2400 | */ | |
|
2401 | Notebook.prototype.list_checkpoints_error = function (xhr, status, error_msg) { | |
|
2402 | this.events.trigger('list_checkpoints_failed.Notebook'); | |
|
2403 | }; | |
|
2404 | ||
|
2405 | /** | |
|
2406 | 2389 | * Create a checkpoint of this notebook on the server from the most recent save. |
|
2407 | 2390 | * |
|
2408 | 2391 | * @method create_checkpoint |
|
2409 | 2392 | */ |
|
2410 | 2393 | Notebook.prototype.create_checkpoint = function () { |
|
2411 | var url = utils.url_join_encode( | |
|
2412 | this.base_url, | |
|
2413 | 'api/contents', | |
|
2414 | this.notebook_path, | |
|
2415 | this.notebook_name, | |
|
2416 |
|
|
|
2417 | ); | |
|
2418 | $.post(url).done( | |
|
2419 | $.proxy(this.create_checkpoint_success, this) | |
|
2420 | ).fail( | |
|
2421 | $.proxy(this.create_checkpoint_error, this) | |
|
2422 | ); | |
|
2394 | var that = this; | |
|
2395 | this.contents.create_checkpoint(this.notebook_path, this.notebook_name, { | |
|
2396 | success_callback: $.proxy(this.create_checkpoint_success, this), | |
|
2397 | error_callback: function (xhr, status, error_msg) { | |
|
2398 | that.events.trigger('checkpoint_failed.Notebook'); | |
|
2399 | } | |
|
2400 | }); | |
|
2423 | 2401 | }; |
|
2424 | 2402 | |
|
2425 | 2403 | /** |
@@ -2436,18 +2414,6 b' define([' | |||
|
2436 | 2414 | this.events.trigger('checkpoint_created.Notebook', data); |
|
2437 | 2415 | }; |
|
2438 | 2416 | |
|
2439 | /** | |
|
2440 | * Failure callback for creating a checkpoint. | |
|
2441 | * | |
|
2442 | * @method create_checkpoint_error | |
|
2443 | * @param {jqXHR} xhr jQuery Ajax object | |
|
2444 | * @param {String} status Description of response status | |
|
2445 | * @param {String} error_msg HTTP error message | |
|
2446 | */ | |
|
2447 | Notebook.prototype.create_checkpoint_error = function (xhr, status, error_msg) { | |
|
2448 | this.events.trigger('checkpoint_failed.Notebook'); | |
|
2449 | }; | |
|
2450 | ||
|
2451 | 2417 | Notebook.prototype.restore_checkpoint_dialog = function (checkpoint) { |
|
2452 | 2418 | var that = this; |
|
2453 | 2419 | checkpoint = checkpoint || this.last_checkpoint; |
@@ -2497,19 +2463,14 b' define([' | |||
|
2497 | 2463 | */ |
|
2498 | 2464 | Notebook.prototype.restore_checkpoint = function (checkpoint) { |
|
2499 | 2465 | this.events.trigger('notebook_restoring.Notebook', checkpoint); |
|
2500 | var url = utils.url_join_encode( | |
|
2501 | this.base_url, | |
|
2502 | 'api/contents', | |
|
2503 | this.notebook_path, | |
|
2504 | this.notebook_name, | |
|
2505 | 'checkpoints', | |
|
2506 |
|
|
|
2507 | ); | |
|
2508 | $.post(url).done( | |
|
2509 | $.proxy(this.restore_checkpoint_success, this) | |
|
2510 | ).fail( | |
|
2511 | $.proxy(this.restore_checkpoint_error, this) | |
|
2512 | ); | |
|
2466 | var that = this; | |
|
2467 | this.contents.restore_checkpoint(this.notebook_path, this.notebook_name, | |
|
2468 | checkpoint, { | |
|
2469 | success_callback: $.proxy(this.create_checkpoint_success, this), | |
|
2470 | error_callback: function (xhr, status, error_msg) { | |
|
2471 | that.events.trigger('checkpoint_restore_failed.Notebook'); | |
|
2472 | } | |
|
2473 | }); | |
|
2513 | 2474 | }; |
|
2514 | 2475 | |
|
2515 | 2476 | /** |
@@ -2526,18 +2487,6 b' define([' | |||
|
2526 | 2487 | }; |
|
2527 | 2488 | |
|
2528 | 2489 | /** |
|
2529 | * Failure callback for restoring a notebook to a checkpoint. | |
|
2530 | * | |
|
2531 | * @method restore_checkpoint_error | |
|
2532 | * @param {jqXHR} xhr jQuery Ajax object | |
|
2533 | * @param {String} status Description of response status | |
|
2534 | * @param {String} error_msg HTTP error message | |
|
2535 | */ | |
|
2536 | Notebook.prototype.restore_checkpoint_error = function (xhr, status, error_msg) { | |
|
2537 | this.events.trigger('checkpoint_restore_failed.Notebook'); | |
|
2538 | }; | |
|
2539 | ||
|
2540 | /** | |
|
2541 | 2490 | * Delete a notebook checkpoint. |
|
2542 | 2491 | * |
|
2543 | 2492 | * @method delete_checkpoint |
@@ -2545,18 +2494,13 b' define([' | |||
|
2545 | 2494 | */ |
|
2546 | 2495 | Notebook.prototype.delete_checkpoint = function (checkpoint) { |
|
2547 | 2496 | this.events.trigger('notebook_restoring.Notebook', checkpoint); |
|
2548 | var url = utils.url_join_encode( | |
|
2549 | this.base_url, | |
|
2550 | 'api/contents', | |
|
2551 | this.notebook_path, | |
|
2552 | this.notebook_name, | |
|
2553 | 'checkpoints', | |
|
2554 |
|
|
|
2555 | ); | |
|
2556 | $.ajax(url, { | |
|
2557 | type: 'DELETE', | |
|
2558 | success: $.proxy(this.delete_checkpoint_success, this), | |
|
2559 | error: $.proxy(this.delete_checkpoint_error, this) | |
|
2497 | var that = this; | |
|
2498 | this.contents.delete_checkpoint(this.notebook_path, this.notebook_name, | |
|
2499 | checkpoint, { | |
|
2500 | success_callback: $.proxy(this.create_checkpoint_success, this), | |
|
2501 | error_callback: function (xhr, status, error_msg) { | |
|
2502 | that.events.trigger('checkpoint_delete_failed.Notebook', [xhr, status, error]); | |
|
2503 | } | |
|
2560 | 2504 | }); |
|
2561 | 2505 | }; |
|
2562 | 2506 | |
@@ -2573,18 +2517,6 b' define([' | |||
|
2573 | 2517 | this.load_notebook(this.notebook_name, this.notebook_path); |
|
2574 | 2518 | }; |
|
2575 | 2519 | |
|
2576 | /** | |
|
2577 | * Failure callback for deleting a notebook checkpoint. | |
|
2578 | * | |
|
2579 | * @method delete_checkpoint_error | |
|
2580 | * @param {jqXHR} xhr jQuery Ajax object | |
|
2581 | * @param {String} status Description of response status | |
|
2582 | * @param {String} error HTTP error message | |
|
2583 | */ | |
|
2584 | Notebook.prototype.delete_checkpoint_error = function (xhr, status, error) { | |
|
2585 | this.events.trigger('checkpoint_delete_failed.Notebook', [xhr, status, error]); | |
|
2586 | }; | |
|
2587 | ||
|
2588 | 2520 | |
|
2589 | 2521 | // For backwards compatability. |
|
2590 | 2522 | IPython.Notebook = Notebook; |
@@ -169,38 +169,44 b' define([' | |||
|
169 | 169 | * Checkpointing Functions |
|
170 | 170 | */ |
|
171 | 171 | |
|
172 |
Contents.prototype. |
|
|
173 | // This is not necessary - integrated into save | |
|
172 | Contents.prototype.create_checkpoint = function(path, name, options) { | |
|
173 | var url = this.api_url(path, name, 'checkpoints'); | |
|
174 | var settings = { | |
|
175 | type : "POST", | |
|
176 | success: options.success_callback || function(data, status, xhr) {}, | |
|
177 | error: options.error_callback || function(xhr, status, error_msg) {} | |
|
178 | }; | |
|
179 | $.ajax(url, settings); | |
|
174 | 180 | }; |
|
175 | 181 | |
|
176 |
Contents.prototype. |
|
|
177 | that = notebook; | |
|
178 | this.events.trigger('notebook_restoring.Notebook', checkpoint); | |
|
179 | var url = this.api_url( | |
|
180 | this.notebook_path, | |
|
181 | this.notebook_name, | |
|
182 | 'checkpoints', | |
|
183 | checkpoint | |
|
184 | ); | |
|
185 | $.post(url).done( | |
|
186 | $.proxy(that.restore_checkpoint_success, that) | |
|
187 | ).fail( | |
|
188 | $.proxy(that.restore_checkpoint_error, that) | |
|
189 | ); | |
|
182 | Contents.prototype.list_checkpoints = function(path, name, options) { | |
|
183 | var url = this.api_url(path, name, 'checkpoints'); | |
|
184 | var settings = { | |
|
185 | type : "GET", | |
|
186 | success: options.success_callback || function(data, status, xhr) {}, | |
|
187 | error: options.error_callback || function(xhr, status, error_msg) {} | |
|
188 | }; | |
|
189 | $.ajax(url, settings); | |
|
190 | 190 | }; |
|
191 | 191 | |
|
192 |
Contents.prototype. |
|
|
193 | that = notebook; | |
|
194 | var url = this.api_url( | |
|
195 | that.notebook_path, | |
|
196 | that.notebook_name, | |
|
197 | 'checkpoints' | |
|
198 |
|
|
|
199 | $.get(url).done( | |
|
200 | $.proxy(that.list_checkpoints_success, that) | |
|
201 | ).fail( | |
|
202 | $.proxy(that.list_checkpoints_error, that) | |
|
203 | ); | |
|
192 | Contents.prototype.restore_checkpoint = function(path, name, checkpoint_id, options) { | |
|
193 | var url = this.api_url(path, name, 'checkpoints', checkpoint_id); | |
|
194 | var settings = { | |
|
195 | type : "POST", | |
|
196 | success: options.success_callback || function(data, status, xhr) {}, | |
|
197 | error: options.error_callback || function(xhr, status, error_msg) {} | |
|
198 | }; | |
|
199 | $.ajax(url, settings); | |
|
200 | }; | |
|
201 | ||
|
202 | Contents.prototype.delete_checkpoint = function(path, name, checkpoint_id, options) { | |
|
203 | var url = this.api_url(path, name, 'checkpoints', checkpoint_id); | |
|
204 | var settings = { | |
|
205 | type : "DELETE", | |
|
206 | success: options.success_callback || function(data, status, xhr) {}, | |
|
207 | error: options.error_callback || function(xhr, status, error_msg) {} | |
|
208 | }; | |
|
209 | $.ajax(url, settings); | |
|
204 | 210 | }; |
|
205 | 211 | |
|
206 | 212 | /** |
@@ -225,7 +231,6 b' define([' | |||
|
225 | 231 | */ |
|
226 | 232 | Contents.prototype.list_contents = function(path, load_callback, |
|
227 | 233 | error_callback) { |
|
228 | var that = this; | |
|
229 | 234 | var settings = { |
|
230 | 235 | processData : false, |
|
231 | 236 | cache : false, |
General Comments 0
You need to be logged in to leave comments.
Login now