Skip to content

Commit 713b054

Browse files
committed
continue to allow notebook contents manager
1 parent 8730fde commit 713b054

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

jupyter_server/serverapp.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import gettext
77
import hashlib
88
import hmac
9+
import inspect
910
import ipaddress
1011
import json
1112
import logging
@@ -132,6 +133,7 @@
132133
MappingKernelManager,
133134
)
134135
from jupyter_server.services.sessions.sessionmanager import SessionManager
136+
from jupyter_server.traittypes import TypeFromClasses
135137
from jupyter_server.utils import (
136138
check_pid,
137139
fetch,
@@ -1433,13 +1435,37 @@ def template_file_path(self):
14331435
help="""If True, display controls to shut down the Jupyter server, such as menu items or buttons.""",
14341436
)
14351437

1436-
contents_manager_class = Type(
1438+
# Temporarily allow content managers to inherit from the 'notebook'
1439+
# package. We will deprecate this in the next major release.
1440+
contents_manager_class = TypeFromClasses(
14371441
default_value=AsyncLargeFileManager,
1438-
klass=ContentsManager,
1442+
klasses=[
1443+
"jupyter_server.services.contents.manager.ContentsManager",
1444+
"notebook.services.contents.manager.ContentsManager",
1445+
],
14391446
config=True,
14401447
help=_i18n("The content manager class to use."),
14411448
)
14421449

1450+
# Throws a deprecation warning to notebook based contents managers.
1451+
@observe("contents_manager_class")
1452+
def _observe_contents_manager_class(self, change):
1453+
new = change["new"]
1454+
# If 'new' is a class, get a string representing the import
1455+
# module path.
1456+
if inspect.isclass(new):
1457+
new = new.__module__
1458+
1459+
if new.startswith("notebook"):
1460+
self.log.warning(
1461+
"The specified 'contents_manager_class' class inherits a manager from the "
1462+
"'notebook' package. This is not guaranteed to work in future "
1463+
"releases of Jupyter Server. Instead, consider switching the "
1464+
"manager to inherit from the 'jupyter_server' managers. "
1465+
"Jupyter Server will temporarily allow 'notebook' managers "
1466+
"until its next major release (3.x)."
1467+
)
1468+
14431469
kernel_manager_class = Type(
14441470
klass=MappingKernelManager,
14451471
config=True,

0 commit comments

Comments
 (0)