@@ -191,12 +191,62 @@ methods:
191
191
ContentsManager.dir_exists
192
192
ContentsManager.is_hidden
193
193
194
+ You may be required to specify a Checkpoints object, as the default one,
195
+ ``FileCheckpoints ``, could be incompatible with your custom
196
+ ContentsManager.
194
197
195
198
Customizing Checkpoints
196
199
-----------------------
200
+ .. currentmodule :: notebook.services.contents.checkpoints
201
+
202
+ Customized Checkpoint definitions allows behavior to be
203
+ altered and extended.
204
+
205
+ The ``Checkpoints `` and ``GenericCheckpointsMixin `` classes
206
+ (from :mod: `notebook.services.contents.checkpoints `)
207
+ have reusable code and are intended to be used together,
208
+ but require the following methods to be implemented.
209
+
210
+ .. autosummary ::
211
+ Checkpoints.rename_checkpoint
212
+ Checkpoints.list_checkpoints
213
+ Checkpoints.delete_checkpoint
214
+ GenericCheckpointsMixin.create_file_checkpoint
215
+ GenericCheckpointsMixin.create_notebook_checkpoint
216
+ GenericCheckpointsMixin.get_file_checkpoint
217
+ GenericCheckpointsMixin.get_notebook_checkpoint
218
+
219
+ No-op example
220
+ ~~~~~~~~~~~~~
197
221
198
- TODO:
222
+ Here is an example of a no-op checkpoints object - note the mixin
223
+ comes first. The docstrings indicate what each method should do or
224
+ return for a more complete implementation.
225
+
226
+ .. code-block :: python
199
227
228
+ class NoOpCheckpoints(GenericCheckpointsMixin, Checkpoints):
229
+ """requires the following methods:"""
230
+ def create_file_checkpoint(self, content, format, path):
231
+ """ -> checkpoint model"""
232
+ def create_notebook_checkpoint(self, nb, path):
233
+ """ -> checkpoint model"""
234
+ def get_file_checkpoint(self, checkpoint_id, path):
235
+ """ -> {'type': 'file', 'content': <str>, 'format': {'text', 'base64'}}"""
236
+ def get_notebook_checkpoint(self, checkpoint_id, path):
237
+ """ -> {'type': 'notebook', 'content': <output of nbformat.read>}"""
238
+ def delete_checkpoint(self, checkpoint_id, path):
239
+ """deletes a checkpoint for a file"""
240
+ def list_checkpoints(self, path):
241
+ """returns a list of checkpoint models for a given file,
242
+ default just does one per file
243
+ """
244
+ return []
245
+ def rename_checkpoint(self, checkpoint_id, old_path, new_path):
246
+ """renames checkpoint from old path to new path"""
247
+
248
+ See ``GenericFileCheckpoints `` in :mod: `notebook.services.contents.filecheckpoints `
249
+ for a more complete example.
200
250
201
251
Testing
202
252
-------
0 commit comments