|
6 | 6 | import gettext
|
7 | 7 | import hashlib
|
8 | 8 | import hmac
|
| 9 | +import inspect |
9 | 10 | import ipaddress
|
10 | 11 | import json
|
11 | 12 | import logging
|
|
132 | 133 | MappingKernelManager,
|
133 | 134 | )
|
134 | 135 | from jupyter_server.services.sessions.sessionmanager import SessionManager
|
| 136 | +from jupyter_server.traittypes import TypeFromClasses |
135 | 137 | from jupyter_server.utils import (
|
136 | 138 | check_pid,
|
137 | 139 | fetch,
|
@@ -1433,13 +1435,37 @@ def template_file_path(self):
|
1433 | 1435 | help="""If True, display controls to shut down the Jupyter server, such as menu items or buttons.""",
|
1434 | 1436 | )
|
1435 | 1437 |
|
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( |
1437 | 1441 | default_value=AsyncLargeFileManager,
|
1438 |
| - klass=ContentsManager, |
| 1442 | + klasses=[ |
| 1443 | + "jupyter_server.services.contents.manager.ContentsManager", |
| 1444 | + "notebook.services.contents.manager.ContentsManager", |
| 1445 | + ], |
1439 | 1446 | config=True,
|
1440 | 1447 | help=_i18n("The content manager class to use."),
|
1441 | 1448 | )
|
1442 | 1449 |
|
| 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 | + |
1443 | 1469 | kernel_manager_class = Type(
|
1444 | 1470 | klass=MappingKernelManager,
|
1445 | 1471 | config=True,
|
|
0 commit comments