##// END OF EJS Templates
handle path separators with os.sep and add tests...
Zachary Sailer -
Show More
@@ -97,17 +97,17 b' class FileNotebookManager(NotebookManager):'
97 changes = data.keys()
97 changes = data.keys()
98 response = 200
98 response = 200
99 for change in changes:
99 for change in changes:
100 full_path = self.get_path(notebook_name, notebook_path)
100 full_path = self.get_os_path(notebook_name, notebook_path)
101 if change == "name":
101 if change == "name":
102 new_path = self.get_path(data['name'], notebook_path)
102 new_path = self.get_os_path(data['name'], notebook_path)
103 if not os.path.isfile(new_path):
103 if not os.path.isfile(new_path):
104 os.rename(full_path,
104 os.rename(full_path,
105 self.get_path(data['name'], notebook_path))
105 self.get_os_path(data['name'], notebook_path))
106 notebook_name = data['name']
106 notebook_name = data['name']
107 else:
107 else:
108 response = 409
108 response = 409
109 if change == "path":
109 if change == "path":
110 new_path = self.get_path(data['name'], data['path'])
110 new_path = self.get_os_path(data['name'], data['path'])
111 stutil.move(full_path, new_path)
111 stutil.move(full_path, new_path)
112 notebook_path = data['path']
112 notebook_path = data['path']
113 if change == "content":
113 if change == "content":
@@ -115,21 +115,45 b' class FileNotebookManager(NotebookManager):'
115 model = self.notebook_model(notebook_name, notebook_path)
115 model = self.notebook_model(notebook_name, notebook_path)
116 return model, response
116 return model, response
117
117
118 def notebook_exists(self, notebook_path):
118 def notebook_exists(self, name, path):
119 """Does a notebook exist?"""
119 """Returns a True if the notebook exists. Else, returns False.
120 return os.path.isfile(notebook_path)
120
121
121 Parameters
122 def get_path(self, notebook_name, notebook_path=None):
122 ----------
123 """Return a full path to a notebook given its notebook_name."""
123 name : string
124 return self.get_path_by_name(notebook_name, notebook_path)
124 The name of the notebook you are checking.
125 path : string
126 The relative path to the notebook (with '/' as separator)
127
128 Returns
129 -------
130 bool
131 """
132 path = self.get_os_path(name, path)
133 return os.path.isfile(path)
125
134
126 def get_path_by_name(self, name, notebook_path=None):
135 def get_os_path(self, fname, path=None):
127 """Return a full path to a notebook given its name."""
136 """Return a full path to a notebook with the os.sep as the separator.
128 filename = name #+ self.filename_ext
137
129 if notebook_path == None:
138 Parameters
130 path = os.path.join(self.notebook_dir, filename)
139 ----------
131 else:
140 fname : string
132 path = os.path.join(self.notebook_dir, notebook_path, filename)
141 The name of a notebook file with the .ipynb extension
142 path : string
143 The relative path (with '/' as separator) to the named notebook.
144
145 Returns
146 -------
147 path :
148 A path that combines notebook_dir (location where server started),
149 the relative path, and the filename with the current operating
150 system's url.
151 """
152 if path is None:
153 path = '/'
154 parts = path.split('/')
155 parts = [p for p in parts if p != ''] # remove duplicate splits
156 path = os.sep.join([self.notebook_dir] + parts + [fname])
133 return path
157 return path
134
158
135 def read_notebook_object_from_path(self, path):
159 def read_notebook_object_from_path(self, path):
@@ -148,7 +172,7 b' class FileNotebookManager(NotebookManager):'
148
172
149 def read_notebook_object(self, notebook_name, notebook_path=None):
173 def read_notebook_object(self, notebook_name, notebook_path=None):
150 """Get the Notebook representation of a notebook by notebook_name."""
174 """Get the Notebook representation of a notebook by notebook_name."""
151 path = self.get_path(notebook_name, notebook_path)
175 path = self.get_os_path(notebook_name, notebook_path)
152 if not os.path.isfile(path):
176 if not os.path.isfile(path):
153 raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_name)
177 raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_name)
154 last_modified, nb = self.read_notebook_object_from_path(path)
178 last_modified, nb = self.read_notebook_object_from_path(path)
@@ -172,7 +196,7 b' class FileNotebookManager(NotebookManager):'
172 old_name = notebook_name
196 old_name = notebook_name
173 old_checkpoints = self.list_checkpoints(old_name)
197 old_checkpoints = self.list_checkpoints(old_name)
174
198
175 path = self.get_path_by_name(new_name, new_path)
199 path = self.get_os_path(new_name, new_path)
176
200
177 # Right before we save the notebook, we write an empty string as the
201 # Right before we save the notebook, we write an empty string as the
178 # notebook name in the metadata. This is to prepare for removing
202 # notebook name in the metadata. This is to prepare for removing
@@ -201,7 +225,7 b' class FileNotebookManager(NotebookManager):'
201 # remove old files if the name changed
225 # remove old files if the name changed
202 if old_name != new_name:
226 if old_name != new_name:
203 # remove renamed original, if it exists
227 # remove renamed original, if it exists
204 old_path = self.get_path_by_name(old_name, notebook_path)
228 old_path = self.get_os_path(old_name, notebook_path)
205 if os.path.isfile(old_path):
229 if os.path.isfile(old_path):
206 self.log.debug("unlinking notebook %s", old_path)
230 self.log.debug("unlinking notebook %s", old_path)
207 os.unlink(old_path)
231 os.unlink(old_path)
@@ -226,7 +250,7 b' class FileNotebookManager(NotebookManager):'
226
250
227 def delete_notebook(self, notebook_name, notebook_path):
251 def delete_notebook(self, notebook_name, notebook_path):
228 """Delete notebook by notebook_name."""
252 """Delete notebook by notebook_name."""
229 nb_path = self.get_path(notebook_name, notebook_path)
253 nb_path = self.get_os_path(notebook_name, notebook_path)
230 if not os.path.isfile(nb_path):
254 if not os.path.isfile(nb_path):
231 raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_name)
255 raise web.HTTPError(404, u'Notebook does not exist: %s' % notebook_name)
232
256
@@ -252,7 +276,7 b' class FileNotebookManager(NotebookManager):'
252 i = 0
276 i = 0
253 while True:
277 while True:
254 name = u'%s%i.ipynb' % (basename,i)
278 name = u'%s%i.ipynb' % (basename,i)
255 path = self.get_path_by_name(name, notebook_path)
279 path = self.get_os_path(name, notebook_path)
256 if not os.path.isfile(path):
280 if not os.path.isfile(path):
257 break
281 break
258 else:
282 else:
@@ -295,7 +319,7 b' class FileNotebookManager(NotebookManager):'
295
319
296 def create_checkpoint(self, notebook_name, notebook_path=None):
320 def create_checkpoint(self, notebook_name, notebook_path=None):
297 """Create a checkpoint from the current state of a notebook"""
321 """Create a checkpoint from the current state of a notebook"""
298 nb_path = self.get_path(notebook_name, notebook_path)
322 nb_path = self.get_os_path(notebook_name, notebook_path)
299 # only the one checkpoint ID:
323 # only the one checkpoint ID:
300 checkpoint_id = u"checkpoint"
324 checkpoint_id = u"checkpoint"
301 cp_path = self.get_checkpoint_path(notebook_name, checkpoint_id, notebook_path)
325 cp_path = self.get_checkpoint_path(notebook_name, checkpoint_id, notebook_path)
@@ -323,7 +347,7 b' class FileNotebookManager(NotebookManager):'
323 def restore_checkpoint(self, notebook_name, checkpoint_id, notebook_path=None):
347 def restore_checkpoint(self, notebook_name, checkpoint_id, notebook_path=None):
324 """restore a notebook to a checkpointed state"""
348 """restore a notebook to a checkpointed state"""
325 self.log.info("restoring Notebook %s from checkpoint %s", notebook_name, checkpoint_id)
349 self.log.info("restoring Notebook %s from checkpoint %s", notebook_name, checkpoint_id)
326 nb_path = self.get_path(notebook_name, notebook_path)
350 nb_path = self.get_os_path(notebook_name, notebook_path)
327 cp_path = self.get_checkpoint_path(notebook_name, checkpoint_id, notebook_path)
351 cp_path = self.get_checkpoint_path(notebook_name, checkpoint_id, notebook_path)
328 if not os.path.isfile(cp_path):
352 if not os.path.isfile(cp_path):
329 self.log.debug("checkpoint file does not exist: %s", cp_path)
353 self.log.debug("checkpoint file does not exist: %s", cp_path)
@@ -74,12 +74,10 b' class NotebookManager(LoggingConfigurable):'
74
74
75 def url_encode(self, path):
75 def url_encode(self, path):
76 parts = os.path.split(path)
76 parts = os.path.split(path)
77 #parts = path.split('/')
78 return os.path.join(*[quote(p) for p in parts])
77 return os.path.join(*[quote(p) for p in parts])
79
78
80 def url_decode(self, path):
79 def url_decode(self, path):
81 parts = os.path.split(path)
80 parts = os.path.split(path)
82 #parts = path.split('/')
83 return os.path.join(*[unquote(p) for p in parts])
81 return os.path.join(*[unquote(p) for p in parts])
84
82
85 def _notebook_dir_changed(self, new):
83 def _notebook_dir_changed(self, new):
@@ -32,6 +32,28 b' class TestFileNotebookManager(TestCase):'
32 with NamedTemporaryFile() as tf:
32 with NamedTemporaryFile() as tf:
33 self.assertRaises(TraitError, FileNotebookManager, notebook_dir=tf.name)
33 self.assertRaises(TraitError, FileNotebookManager, notebook_dir=tf.name)
34
34
35 def test_get_os_path(self):
36 # full filesystem path should be returned with correct operating system
37 # separators.
38 with TemporaryDirectory() as td:
39 nbdir = os.path.join(td, 'notebooks')
40 km = FileNotebookManager(notebook_dir=nbdir)
41 path = km.get_os_path('test.ipynb', '/path/to/notebook/')
42 self.assertEqual(path, km.notebook_dir+os.sep+'path'+os.sep+'to'+os.sep+
43 'notebook'+os.sep+'test.ipynb')
44
45 with TemporaryDirectory() as td:
46 nbdir = os.path.join(td, 'notebooks')
47 km = FileNotebookManager(notebook_dir=nbdir)
48 path = km.get_os_path('test.ipynb', None)
49 self.assertEqual(path, km.notebook_dir+os.sep+'test.ipynb')
50
51 with TemporaryDirectory() as td:
52 nbdir = os.path.join(td, 'notebooks')
53 km = FileNotebookManager(notebook_dir=nbdir)
54 path = km.get_os_path('test.ipynb', '////')
55 self.assertEqual(path, km.notebook_dir+os.sep+'test.ipynb')
56
35 class TestNotebookManager(TestCase):
57 class TestNotebookManager(TestCase):
36 def test_named_notebook_path(self):
58 def test_named_notebook_path(self):
37 nm = NotebookManager()
59 nm = NotebookManager()
@@ -50,7 +50,6 b' var IPython = (function (IPython) {'
50 // single worksheet for now
50 // single worksheet for now
51 this.worksheet_metadata = {};
51 this.worksheet_metadata = {};
52 this.control_key_active = false;
52 this.control_key_active = false;
53 this.notebook_name = null;
54 this.notebook_name_blacklist_re = /[\/\\:]/;
53 this.notebook_name_blacklist_re = /[\/\\:]/;
55 this.nbformat = 3 // Increment this when changing the nbformat
54 this.nbformat = 3 // Increment this when changing the nbformat
56 this.nbformat_minor = 0 // Increment this when changing the nbformat
55 this.nbformat_minor = 0 // Increment this when changing the nbformat
@@ -87,14 +86,7 b' var IPython = (function (IPython) {'
87 Notebook.prototype.notebookPath = function() {
86 Notebook.prototype.notebookPath = function() {
88 var path = $('body').data('notebookPath');
87 var path = $('body').data('notebookPath');
89 path = decodeURIComponent(path);
88 path = decodeURIComponent(path);
90 if (path != 'None') {
89 return path
91 if (path[path.length-1] != '/') {
92 path = path.substring(0,path.length);
93 };
94 return path;
95 } else {
96 return '';
97 }
98 };
90 };
99
91
100 /**
92 /**
@@ -1368,7 +1360,7 b' var IPython = (function (IPython) {'
1368 var cells = this.get_cells();
1360 var cells = this.get_cells();
1369 for (var i=0; i<ncells; i++) {
1361 for (var i=0; i<ncells; i++) {
1370 if (cells[i] instanceof IPython.CodeCell) {
1362 if (cells[i] instanceof IPython.CodeCell) {
1371 cells[i].clear_output();
1363 cells[i].clear_output(true,true,true);
1372 // Make all In[] prompts blank, as well
1364 // Make all In[] prompts blank, as well
1373 // TODO: make this configurable (via checkbox?)
1365 // TODO: make this configurable (via checkbox?)
1374 cells[i].set_input_prompt();
1366 cells[i].set_input_prompt();
@@ -1397,8 +1389,7 b' var IPython = (function (IPython) {'
1397 * @method start_session
1389 * @method start_session
1398 */
1390 */
1399 Notebook.prototype.start_session = function () {
1391 Notebook.prototype.start_session = function () {
1400 var notebook_info = this.notebookPath() + this.notebook_name;
1392 this.session = new IPython.Session(this.notebook_name, this.notebook_path, this);
1401 this.session = new IPython.Session(notebook_info, this);
1402 this.session.start();
1393 this.session.start();
1403 this.link_cells_to_session();
1394 this.link_cells_to_session();
1404 };
1395 };
@@ -1527,7 +1518,7 b' var IPython = (function (IPython) {'
1527 * @return {String} This notebook's name
1518 * @return {String} This notebook's name
1528 */
1519 */
1529 Notebook.prototype.get_notebook_name = function () {
1520 Notebook.prototype.get_notebook_name = function () {
1530 nbname = this.notebook_name.substring(0,this.notebook_name.length-6);
1521 var nbname = this.notebook_name.substring(0,this.notebook_name.length-6);
1531 return nbname;
1522 return nbname;
1532 };
1523 };
1533
1524
@@ -1566,7 +1557,7 b' var IPython = (function (IPython) {'
1566 * @param {Object} data JSON representation of a notebook
1557 * @param {Object} data JSON representation of a notebook
1567 */
1558 */
1568 Notebook.prototype.fromJSON = function (data) {
1559 Notebook.prototype.fromJSON = function (data) {
1569 data = data.content;
1560 var content = data.content;
1570 var ncells = this.ncells();
1561 var ncells = this.ncells();
1571 var i;
1562 var i;
1572 for (i=0; i<ncells; i++) {
1563 for (i=0; i<ncells; i++) {
@@ -1574,10 +1565,10 b' var IPython = (function (IPython) {'
1574 this.delete_cell(0);
1565 this.delete_cell(0);
1575 };
1566 };
1576 // Save the metadata and name.
1567 // Save the metadata and name.
1577 this.metadata = data.metadata;
1568 this.metadata = content.metadata;
1578 this.notebook_name = data.metadata.name +'.ipynb';
1569 this.notebook_name = data.name;
1579 // Only handle 1 worksheet for now.
1570 // Only handle 1 worksheet for now.
1580 var worksheet = data.worksheets[0];
1571 var worksheet = content.worksheets[0];
1581 if (worksheet !== undefined) {
1572 if (worksheet !== undefined) {
1582 if (worksheet.metadata) {
1573 if (worksheet.metadata) {
1583 this.worksheet_metadata = worksheet.metadata;
1574 this.worksheet_metadata = worksheet.metadata;
@@ -1598,7 +1589,7 b' var IPython = (function (IPython) {'
1598 new_cell.fromJSON(cell_data);
1589 new_cell.fromJSON(cell_data);
1599 };
1590 };
1600 };
1591 };
1601 if (data.worksheets.length > 1) {
1592 if (content.worksheets.length > 1) {
1602 IPython.dialog.modal({
1593 IPython.dialog.modal({
1603 title : "Multiple worksheets",
1594 title : "Multiple worksheets",
1604 body : "This notebook has " + data.worksheets.length + " worksheets, " +
1595 body : "This notebook has " + data.worksheets.length + " worksheets, " +
@@ -1672,10 +1663,13 b' var IPython = (function (IPython) {'
1672 Notebook.prototype.save_notebook = function () {
1663 Notebook.prototype.save_notebook = function () {
1673 // We may want to move the name/id/nbformat logic inside toJSON?
1664 // We may want to move the name/id/nbformat logic inside toJSON?
1674 var data = this.toJSON();
1665 var data = this.toJSON();
1675 data.metadata.name = this.notebook_name;
1666 var model = {};
1676 data.nbformat = this.nbformat;
1667 // Create a JSON model to be sent to the server.
1677 data.nbformat_minor = this.nbformat_minor;
1668 model['name'] = this.notebook_name;
1678
1669 model['path'] = this.notebook_path;
1670 model['content'] = data
1671 model.content.nbformat = this.nbformat;
1672 model.content.nbformat_minor = this.nbformat_minor;
1679 // time the ajax call for autosave tuning purposes.
1673 // time the ajax call for autosave tuning purposes.
1680 var start = new Date().getTime();
1674 var start = new Date().getTime();
1681 // We do the call with settings so we can set cache to false.
1675 // We do the call with settings so we can set cache to false.
@@ -1683,13 +1677,13 b' var IPython = (function (IPython) {'
1683 processData : false,
1677 processData : false,
1684 cache : false,
1678 cache : false,
1685 type : "PUT",
1679 type : "PUT",
1686 data : JSON.stringify(data),
1680 data : JSON.stringify(model),
1687 headers : {'Content-Type': 'application/json'},
1681 headers : {'Content-Type': 'application/json'},
1688 success : $.proxy(this.save_notebook_success, this, start),
1682 success : $.proxy(this.save_notebook_success, this, start),
1689 error : $.proxy(this.save_notebook_error, this)
1683 error : $.proxy(this.save_notebook_error, this)
1690 };
1684 };
1691 $([IPython.events]).trigger('notebook_saving.Notebook');
1685 $([IPython.events]).trigger('notebook_saving.Notebook');
1692 var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath()+ this.notebook_name;
1686 var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath()+ this.notebook_name;
1693 $.ajax(url, settings);
1687 $.ajax(url, settings);
1694 };
1688 };
1695
1689
@@ -1752,14 +1746,15 b' var IPython = (function (IPython) {'
1752 type : "POST",
1746 type : "POST",
1753 dataType : "json",
1747 dataType : "json",
1754 success:$.proxy(function (data, status, xhr){
1748 success:$.proxy(function (data, status, xhr){
1755 notebook_name = data.name;
1749 var notebook_name = data.name;
1756 window.open(this._baseProjectUrl +'notebooks/' + this.notebookPath()+ notebook_name);
1750 window.open(this.baseProjectUrl() +'notebooks' + this.notebookPath()+ notebook_name, '_blank');
1757 }, this)
1751 }, this)
1758 };
1752 };
1759 var url = this._baseProjectUrl + 'notebooks/' + path;
1753 var url = this.baseProjectUrl() + 'api/notebooks' + path;
1760 $.ajax(url,settings);
1754 $.ajax(url,settings);
1761 };
1755 };
1762
1756
1757
1763 Notebook.prototype.copy_notebook = function(){
1758 Notebook.prototype.copy_notebook = function(){
1764 var path = this.notebookPath();
1759 var path = this.notebookPath();
1765 var name = {'name': this.notebook_name}
1760 var name = {'name': this.notebook_name}
@@ -1771,10 +1766,10 b' var IPython = (function (IPython) {'
1771 dataType : "json",
1766 dataType : "json",
1772 success:$.proxy(function (data, status, xhr){
1767 success:$.proxy(function (data, status, xhr){
1773 notebook_name = data.name;
1768 notebook_name = data.name;
1774 window.open(this._baseProjectUrl +'notebooks/' + this.notebookPath()+ notebook_name);
1769 window.open(this._baseProjectUrl +'notebooks' + this.notebookPath()+ notebook_name);
1775 }, this)
1770 }, this)
1776 };
1771 };
1777 var url = this._baseProjectUrl + 'notebooks/' + path;
1772 var url = this._baseProjectUrl + 'notebooks' + path;
1778 $.ajax(url,settings);
1773 $.ajax(url,settings);
1779 };
1774 };
1780
1775
@@ -1793,15 +1788,16 b' var IPython = (function (IPython) {'
1793 error : $.proxy(that.rename_error, this)
1788 error : $.proxy(that.rename_error, this)
1794 };
1789 };
1795 $([IPython.events]).trigger('notebook_rename.Notebook');
1790 $([IPython.events]).trigger('notebook_rename.Notebook');
1796 var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath()+ this.notebook_name;
1791 var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath()+ this.notebook_name;
1797 $.ajax(url, settings);
1792 $.ajax(url, settings);
1798 };
1793 };
1799
1794
1800
1795
1801 Notebook.prototype.rename_success = function (json, status, xhr) {
1796 Notebook.prototype.rename_success = function (json, status, xhr) {
1802 this.notebook_name = json.name
1797 this.notebook_name = json.name
1803 var notebook_path = this.notebookPath() + this.notebook_name;
1798 var name = this.notebook_name
1804 this.session.notebook_rename(notebook_path);
1799 var path = json.path
1800 this.session.notebook_rename(name, path);
1805 $([IPython.events]).trigger('notebook_renamed.Notebook');
1801 $([IPython.events]).trigger('notebook_renamed.Notebook');
1806 }
1802 }
1807
1803
@@ -1855,7 +1851,7 b' var IPython = (function (IPython) {'
1855 error : $.proxy(this.load_notebook_error,this),
1851 error : $.proxy(this.load_notebook_error,this),
1856 };
1852 };
1857 $([IPython.events]).trigger('notebook_loading.Notebook');
1853 $([IPython.events]).trigger('notebook_loading.Notebook');
1858 var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath() + this.notebook_name;
1854 var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath() + this.notebook_name;
1859 $.ajax(url, settings);
1855 $.ajax(url, settings);
1860 };
1856 };
1861
1857
@@ -1916,7 +1912,7 b' var IPython = (function (IPython) {'
1916 // Create the session after the notebook is completely loaded to prevent
1912 // Create the session after the notebook is completely loaded to prevent
1917 // code execution upon loading, which is a security risk.
1913 // code execution upon loading, which is a security risk.
1918 if (this.session == null) {
1914 if (this.session == null) {
1919 this.start_session(this.notebook_path);
1915 this.start_session();
1920 }
1916 }
1921 // load our checkpoint list
1917 // load our checkpoint list
1922 IPython.notebook.list_checkpoints();
1918 IPython.notebook.list_checkpoints();
@@ -1988,7 +1984,7 b' var IPython = (function (IPython) {'
1988 * @method list_checkpoints
1984 * @method list_checkpoints
1989 */
1985 */
1990 Notebook.prototype.list_checkpoints = function () {
1986 Notebook.prototype.list_checkpoints = function () {
1991 var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath() + this.notebook_name + '/checkpoints';
1987 var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath() + this.notebook_name + '/checkpoints';
1992 $.get(url).done(
1988 $.get(url).done(
1993 $.proxy(this.list_checkpoints_success, this)
1989 $.proxy(this.list_checkpoints_success, this)
1994 ).fail(
1990 ).fail(
@@ -2033,7 +2029,7 b' var IPython = (function (IPython) {'
2033 * @method create_checkpoint
2029 * @method create_checkpoint
2034 */
2030 */
2035 Notebook.prototype.create_checkpoint = function () {
2031 Notebook.prototype.create_checkpoint = function () {
2036 var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath() + this.notebook_name + '/checkpoints';
2032 var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath() + this.notebook_name + '/checkpoints';
2037 $.post(url).done(
2033 $.post(url).done(
2038 $.proxy(this.create_checkpoint_success, this)
2034 $.proxy(this.create_checkpoint_success, this)
2039 ).fail(
2035 ).fail(
@@ -2113,18 +2109,8 b' var IPython = (function (IPython) {'
2113 * @param {String} checkpoint ID
2109 * @param {String} checkpoint ID
2114 */
2110 */
2115 Notebook.prototype.restore_checkpoint = function (checkpoint) {
2111 Notebook.prototype.restore_checkpoint = function (checkpoint) {
2116 <<<<<<< HEAD
2117 $([IPython.events]).trigger('checkpoint_restoring.Notebook', checkpoint);
2118 if (this.notebook_path != "") {
2119 var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebook_path + this.notebook_name + '/checkpoints/' + checkpoint;
2120 }
2121 else {
2122 var url = this.baseProjectUrl() + 'api/notebooks/' +this.notebook_name + '/checkpoints/' + checkpoint;
2123 }
2124 =======
2125 $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
2112 $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
2126 var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath() + this.notebook_name + '/checkpoints/' + checkpoint;
2113 var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath() + this.notebook_name + '/checkpoints/' + checkpoint;
2127 >>>>>>> fixing path redirects, cleaning path logic
2128 $.post(url).done(
2114 $.post(url).done(
2129 $.proxy(this.restore_checkpoint_success, this)
2115 $.proxy(this.restore_checkpoint_success, this)
2130 ).fail(
2116 ).fail(
@@ -2165,7 +2151,7 b' var IPython = (function (IPython) {'
2165 */
2151 */
2166 Notebook.prototype.delete_checkpoint = function (checkpoint) {
2152 Notebook.prototype.delete_checkpoint = function (checkpoint) {
2167 $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
2153 $([IPython.events]).trigger('notebook_restoring.Notebook', checkpoint);
2168 var url = this.baseProjectUrl() + 'api/notebooks/' + this.notebookPath() + this.notebook_name + '/checkpoints/' + checkpoint;
2154 var url = this.baseProjectUrl() + 'api/notebooks' + this.notebookPath() + this.notebook_name + '/checkpoints/' + checkpoint;
2169 $.ajax(url, {
2155 $.ajax(url, {
2170 type: 'DELETE',
2156 type: 'DELETE',
2171 success: $.proxy(this.delete_checkpoint_success, this),
2157 success: $.proxy(this.delete_checkpoint_success, this),
@@ -2205,4 +2191,3 b' var IPython = (function (IPython) {'
2205 return IPython;
2191 return IPython;
2206
2192
2207 }(IPython));
2193 }(IPython));
2208
General Comments 0
You need to be logged in to leave comments. Login now