diff --git a/notebook/services/contents/checkpoints.py b/notebook/services/contents/checkpoints.py index 1087214a4..c29a669c2 100644 --- a/notebook/services/contents/checkpoints.py +++ b/notebook/services/contents/checkpoints.py @@ -67,7 +67,7 @@ class GenericCheckpointsMixin(object): - get_notebook_checkpoint(self, checkpoint_id, path) To create a generic CheckpointManager, add this mixin to a class that - implement the above three methods plus the remaining Checkpoints API + implement the above four methods plus the remaining Checkpoints API methods: - delete_checkpoint(self, checkpoint_id, path) @@ -118,10 +118,25 @@ class GenericCheckpointsMixin(object): """ raise NotImplementedError("must be implemented in a subclass") - def get_checkpoint(self, checkpoint_id, path, type): - """Get the content of a checkpoint. + def get_file_checkpoint(self, checkpoint_id, path): + """Get the content of a checkpoint for a non-notebook file. - Returns an unvalidated model with the same structure as - the return value of ContentsManager.get + Returns a dict of the form: + { + 'type': 'file', + 'content': , + 'format': {'text','base64'}, + } + """ + raise NotImplementedError("must be implemented in a subclass") + + def get_notebook_checkpoint(self, checkpoint_id, path): + """Get the content of a checkpoint for a notebook. + + Returns a dict of the form: + { + 'type': 'notebook', + 'content': , + } """ raise NotImplementedError("must be implemented in a subclass") diff --git a/notebook/services/contents/filecheckpoints.py b/notebook/services/contents/filecheckpoints.py index f6dd9b6bc..46e32eadc 100644 --- a/notebook/services/contents/filecheckpoints.py +++ b/notebook/services/contents/filecheckpoints.py @@ -142,7 +142,7 @@ class GenericFileCheckpoints(GenericCheckpointsMixin, FileCheckpoints): ContentsManager. """ def create_file_checkpoint(self, content, format, path): - """Create a checkpoint from the current content of a notebook.""" + """Create a checkpoint from the current content of a file.""" path = path.strip('/') # only the one checkpoint ID: checkpoint_id = u"checkpoint" @@ -168,7 +168,7 @@ class GenericFileCheckpoints(GenericCheckpointsMixin, FileCheckpoints): return self.checkpoint_model(checkpoint_id, os_checkpoint_path) def get_notebook_checkpoint(self, checkpoint_id, path): - + """Get a checkpoint for a notebook.""" path = path.strip('/') self.log.info("restoring %s from checkpoint %s", path, checkpoint_id) os_checkpoint_path = self.checkpoint_path(checkpoint_id, path) @@ -185,6 +185,7 @@ class GenericFileCheckpoints(GenericCheckpointsMixin, FileCheckpoints): } def get_file_checkpoint(self, checkpoint_id, path): + """Get a checkpoint for a file.""" path = path.strip('/') self.log.info("restoring %s from checkpoint %s", path, checkpoint_id) os_checkpoint_path = self.checkpoint_path(checkpoint_id, path)