Skip to content

Updated to support Jupyter Notebook 7 and Jupyter Lab #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions pgcontents/pgmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
from __future__ import unicode_literals
from itertools import chain
from tornado import web
from traitlets import default
from traitlets import (
Unicode,
default,
)

from jupyter_server.transutils import _i18n

from .api_utils import (
base_directory_model,
Expand Down Expand Up @@ -65,10 +70,22 @@ class PostgresContentsManager(PostgresManagerMixin, ContentsManager):
ContentsManager that persists to a postgres database rather than to the
local filesystem.
"""


create_directory_on_startup = Bool(
config=True,
help="Create a root directory automatically?",
)

root_dir = Unicode("/", config=True)

preferred_dir = Unicode(
"",
config=True,
help=_i18n(
"Preferred starting directory to use for notebooks. This is an API path (`/` separated, relative to root dir)"
),
)

@default('checkpoints_class')
def _default_checkpoints_class(self):
Expand Down Expand Up @@ -102,7 +119,7 @@ def __init__(self, *args, **kwargs):

def ensure_root_directory(self):
with self.engine.begin() as db:
ensure_directory(db, self.user_id, '')
ensure_directory(db, self.user_id, self.root_dir)

def purge_db(self):
"""
Expand Down
11 changes: 6 additions & 5 deletions pgcontents/utils/ipycompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
Utilities for managing compat between notebook versions.
"""
from traitlets.config import Config
from notebook.services.contents.checkpoints import (

from jupyter_server.services.contents.checkpoints import (
Checkpoints,
GenericCheckpointsMixin,
)
from notebook.services.contents.filemanager import FileContentsManager
from notebook.services.contents.filecheckpoints import (
from jupyter_server.services.contents.filemanager import FileContentsManager
from jupyter_server.services.contents.filecheckpoints import (
GenericFileCheckpoints
)
from notebook.services.contents.manager import ContentsManager
from notebook.utils import to_os_path
from jupyter_server.services.contents.manager import ContentsManager
from jupyter_server.utils import to_os_path
from nbformat import from_dict, reads, writes
from nbformat.v4.nbbase import (
new_code_cell,
Expand Down