Commit Graph

46 Commits

Author SHA1 Message Date
Scott Sanderson
1e2e86dcca MAINT: Return dicts from CheckpointManager.get_checkpoint.
The output is going to get converted to a dict anyway, and this makes it
easier to pipe output from a CheckpointManager directly to a
ContentsManager.
2015-01-06 14:28:59 -05:00
Scott Sanderson
7030a8717a DEV: Add full support for non-notebook checkpoints. 2015-01-01 20:52:00 -05:00
Scott Sanderson
f71f216880 DEV: More checkpoint API refactoring.
Changed the public checkpoint API to:
- `create_checkpoint(self, nb, path)`
- `get_checkpoint_content(self, checkpoint_id, path)`
- `rename_checkpoint(self, checkpoint_id, old_path, new_path)`
- `delete_checkpoint(self, checkpoint_id, path)`
- `list_checkpoints(self, path)`

All paths in the above are API-style paths, and the `nb` argument to
`create_checkpoint` is a dictionary suitable for passing to
`nbformat.write`.

The new `get_checkpoint_content` method returns an unvalidated notebook
content dictionary.  It is used by `ContentManager.restore_checkpoint`
to load content to be written via `save`.
2014-12-29 07:00:30 -05:00
Scott Sanderson
4da8a30f20 DEV: Refactor checkpoint logic from FileContentsManager.
- Add a `CheckpointManager` base class and infrastructure for creating a
  `checkpoint_manager` instance attribute on `ContentsManager`.

- Provide default implementations of `delete` and `rename` in the base
  `ContentsManager` class.  `ContentsManager` subclasses are now
  required to implement `delete_file` and `rename_file`.  These methods
  no longer need to manage checkpoints.

- Move checkpoint-related functionality from `FileContentsManager` to a
  dedicated `FileCheckpointManager` subclass.

- Move shared filesystem interaction logic into `FileManagerMixin`
  used by both `FileContentsManager` and `FileCheckpointManager`.

- Minor tweaks to ContentsManager tests to get methods from the right
  object.

The purpose of this change is to provide an API for users to replace
just the checkpoint logic associated with a particular
`ContentsManager`.  In particular, this change makes it possible to
easily support remote storage of checkpoints while otherwise retaining
normal filesystem interactions.
2014-12-27 00:23:14 -05:00
Scott Sanderson
9aad3c631f MAINT: Move update from FileContentsManager to ContentsManager.
The implementation in FileContentsManager is written entirely in terms
of the required API, and is sensible for other ContentsManager
implementations.
2014-12-25 13:17:10 -05:00
Scott Sanderson
7ab1bf7487 BUG: Set default mimetype when base64 is requested 2014-12-17 11:38:44 -08:00
Min RK
42a92d4794 Merge pull request #6896 from minrk/save-hooks
Proposal: add pre/post-save hooks
2014-12-12 11:14:18 -08:00
Min RK
22e206de6f ContentsManager type kwarg to match model key
remove `_` suffix, making it consistent with models,
REST API, etc.
2014-12-09 14:53:08 -08:00
Thomas Kluyver
4cee2f5f3a Merge pull request #7128 from minrk/more-v-less-m
A little more V, a little less M in the text editor
2014-12-09 14:03:04 -08:00
Min RK
407e63cb80 set default mimetype to octet-stream for binary files
mimetype only specified if content=True
2014-12-08 14:31:32 -08:00
Min RK
c81609f5d6 redirect /edit/ to /files/ if not (utf8) text 2014-12-08 11:34:21 -08:00
Min RK
ee00dcf083 docstring 2014-12-07 11:20:30 -08:00
Min RK
f2343e4ec5 update --script behavior to use nbconvert --to script 2014-12-07 11:18:59 -08:00
Min RK
1731b9b449 --script triggers post_save hook with nbconvert 2014-12-07 11:18:59 -08:00
Min RK
58c0a97ec3 add pre/post-save hooks
- `ContentsManager.pre_save_hook` runs on the path and model with content
- `FileContentsManager.post_save_hook` runs on the filesystem path and model without content

- use pre_save_hook for things like stripping output
- use post_save_hook for things like nbconvert --to python
2014-12-07 11:18:58 -08:00
Matthias Bussonnier
de52775797 Merge pull request #7078 from takluyver/kernelpath
Rework get_kernel_path logic
2014-12-04 16:59:54 +01:00
Matthias Bussonnier
fd2588612a return API path instead of filesystem 2014-11-28 11:31:22 +01:00
Thomas Kluyver
25ee73a554 Loading a file works 2014-11-20 11:52:35 -08:00
Min RK
837ef7f122 s/open_w/atomic_writing/ 2014-11-19 19:56:54 -08:00
Min RK
c9a4e5b00d handle various permission failures
- turn various EPERM, EACCES errors into 403
- add `writable` bool field to contents models
- if a notebook is not `writable`, save is disabled
2014-11-19 19:56:52 -08:00
Thomas Kluyver
8252f56b00 Allow FileContentsManager and MappingKernelManager to be used outside NotebookApp 2014-11-18 17:41:21 -08:00
Thomas Kluyver
6d776a5292 Allow starting the server with both file_to_run and notebook_dir
file_to_run and notebook_dir would collide, with possible dictionary
ordering randomness depending on how they were passed.

With this change, the default value of notebook_dir is pulled from
file_to_run, instead of pushing the value when file_to_run is changed.
This makes it possible to specify both and have the server behave as
expected.
2014-11-18 17:41:21 -08:00
Thomas Kluyver
f1f81e2efa Rename get_model() to get() 2014-11-11 14:51:21 -08:00
Thomas Kluyver
6f48b58b18 Fix various review comments 2014-11-11 14:46:53 -08:00
Thomas Kluyver
b5a6cb7da1 Allow specifying format when getting files from contents API 2014-11-11 14:20:56 -08:00
Thomas Kluyver
ce6dd40c5c Add type parameter for contents GET requests 2014-11-11 12:17:36 -08:00
Min RK
39041a9f03 address review in contents service
- various docstrings, comments clarified and updated
- misc typos
- fix and test creating an untitled directory via POST
- only define `message` if there's something to say
2014-11-10 14:02:21 -08:00
MinRK
3ada0c2c27 Remove separate 'path', 'name' in Contents API
- path is full path (including name)
- name is only used for read-only convenience, and plays no role in any API
- remove 'untitled upload' (POST with content and no path)
2014-11-10 14:02:18 -08:00
Min RK
525f6a7561 fix backward f, nb args for nbformat.write 2014-11-01 16:41:13 -07:00
MinRK
af735018f3 don't use nbformat.current in IPython.html
use top-level nbformat.read/write, v4 directly for compose
2014-11-01 16:41:11 -07:00
MinRK
12f94ae2a2 use from_dict for dict->notebook
not confusing to_notebook_json
2014-11-01 16:41:09 -07:00
MinRK
dd95b1ef5f remove heading cells in v4 2014-11-01 16:41:07 -07:00
MinRK
b2d946d44e don't convert notebooks on upload 2014-10-08 12:33:34 -07:00
MinRK
ddd3aa2a5a add dialogs for failed save/load
- failed validation doesn't prevent save/load,
  but the user is now warned about it.
- there is now a warning dialog if fromJSON fails,
  rather than the usual silent failure.
2014-10-08 12:33:32 -07:00
Thomas Kluyver
81b06d81a1 Merge pull request #6358 from minrk/contents-missing
fix directory listing with broken symlinks
2014-09-04 14:43:45 -07:00
MinRK
819c3c326c fix directory listing with broken symlinks
directory listing would 404 if any listed file doesn't exist
(e.g. symlink to missing target).

Previously-failing test included.
2014-08-26 09:12:54 -07:00
Thomas Kluyver
8b7d4c1c2f Rework atomic_writing with tests & docstring 2014-08-05 10:50:09 -07:00
Thomas Kluyver
04cbce2a14 Implement atomic save
Ping @fperez, this should avoid issues with corrupted/lost notebooks
when the disk is full, though I haven't worked out how to test it just
yet.

Closes gh-6254
2014-08-04 11:22:42 -07:00
MinRK
3e79eea46b update contents per further review
- fix is_hidden always returning True on nonexistent files
- create hidden dir fails with 400
- don't read binary files twice
- logging improvements
- dialog on invalid notebook upload
- warn about disabled `--save`
2014-07-31 11:57:38 -07:00
MinRK
3c26b079f0 updates per review
- clarified docstrings and errors
- still more notebook/file renames
- configurable untitled names
- copy_from can be full path
- fix running, upload, new-tab behaviors in dashboard

Yay, review!
2014-07-31 11:57:38 -07:00
MinRK
bec995aa63 updates per review
a few more notebook mentions in docstrings,
and inappropriate use of setdefault.
2014-07-31 11:57:37 -07:00
MinRK
93b300adda support deleting empty directories
can’t copy directories
2014-07-31 11:57:37 -07:00
MinRK
260afd76ae contents service review
- missed some s/notebook/file/ in docstrings
- manager doesn’t sort contents
2014-07-31 11:57:37 -07:00
MinRK
8c4069cc00 add support and tests for uploading and saving regular files 2014-07-31 11:57:36 -07:00
MinRK
0c0eb43719 teach contents service about non-notebook files 2014-07-31 11:57:36 -07:00
MinRK
6cce477e07 rename notebooks service to contents service
minimal functional changes, committing because tests are passing.
2014-07-31 11:57:36 -07:00