From 3a4d719033defcb7bac1239ac1a8fc114b49f91d Mon Sep 17 00:00:00 2001 From: MinRK Date: Wed, 23 Oct 2013 10:37:08 -0700 Subject: [PATCH 1/2] fix checkpoint filename --- IPython/html/services/notebooks/filenbmanager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IPython/html/services/notebooks/filenbmanager.py b/IPython/html/services/notebooks/filenbmanager.py index e87a2ccb2..41b89abb5 100644 --- a/IPython/html/services/notebooks/filenbmanager.py +++ b/IPython/html/services/notebooks/filenbmanager.py @@ -326,8 +326,9 @@ class FileNotebookManager(NotebookManager): def get_checkpoint_path(self, checkpoint_id, name, path=''): """find the path to a checkpoint""" path = path.strip('/') + basename, _ = os.path.splitext(name) filename = u"{name}-{checkpoint_id}{ext}".format( - name=name, + name=basename, checkpoint_id=checkpoint_id, ext=self.filename_ext, ) From 6bc2c65c839e953eb0db6f21d3937147850ecf59 Mon Sep 17 00:00:00 2001 From: MinRK Date: Wed, 23 Oct 2013 10:37:49 -0700 Subject: [PATCH 2/2] notebooks should always have one checkpoint closes #4396 --- IPython/html/services/notebooks/filenbmanager.py | 4 ++++ IPython/html/services/notebooks/nbmanager.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/IPython/html/services/notebooks/filenbmanager.py b/IPython/html/services/notebooks/filenbmanager.py index 41b89abb5..992e9d39c 100644 --- a/IPython/html/services/notebooks/filenbmanager.py +++ b/IPython/html/services/notebooks/filenbmanager.py @@ -222,6 +222,10 @@ class FileNotebookManager(NotebookManager): if 'content' not in model: raise web.HTTPError(400, u'No notebook JSON data provided') + + # One checkpoint should always exist + if self.notebook_exists(name, path) and not self.list_checkpoints(name, path): + self.create_checkpoint(name, path) new_path = model.get('path', path).strip('/') new_name = model.get('name', name) diff --git a/IPython/html/services/notebooks/nbmanager.py b/IPython/html/services/notebooks/nbmanager.py index 568c6a5f0..c9d5459b3 100644 --- a/IPython/html/services/notebooks/nbmanager.py +++ b/IPython/html/services/notebooks/nbmanager.py @@ -117,7 +117,7 @@ class NotebookManager(LoggingConfigurable): raise NotImplementedError('must be implemented in a subclass') def create_notebook_model(self, model=None, path=''): - """Create a new untitled notebook and return its model with no content.""" + """Create a new notebook and return its model with no content.""" path = path.strip('/') if model is None: model = {}