|
31 | 31 | import warnings
|
32 | 32 | import webbrowser
|
33 | 33 | import urllib
|
| 34 | +import inspect |
34 | 35 |
|
35 | 36 | from base64 import encodebytes
|
36 | 37 | try:
|
|
106 | 107 | from jupyter_server.extension.serverextension import ServerExtensionApp
|
107 | 108 | from jupyter_server.extension.manager import ExtensionManager
|
108 | 109 | from jupyter_server.extension.config import ExtensionConfigManager
|
| 110 | +from jupyter_server.traittypes import TypeFromClasses |
109 | 111 |
|
110 | 112 | #-----------------------------------------------------------------------------
|
111 | 113 | # Module globals
|
@@ -1134,13 +1136,43 @@ def template_file_path(self):
|
1134 | 1136 | help="""If True, display controls to shut down the Jupyter server, such as menu items or buttons."""
|
1135 | 1137 | )
|
1136 | 1138 |
|
1137 |
| - contents_manager_class = Type( |
| 1139 | + # REMOVE in VERSION 2.0 |
| 1140 | + # Temporarily allow content managers to inherit from the 'notebook' |
| 1141 | + # package. We will deprecate this in the next major release. |
| 1142 | + contents_manager_class = TypeFromClasses( |
1138 | 1143 | default_value=LargeFileManager,
|
1139 |
| - klass=ContentsManager, |
| 1144 | + klasses=[ |
| 1145 | + 'jupyter_server.services.contents.manager.ContentsManager', |
| 1146 | + 'notebook.services.contents.manager.ContentsManager' |
| 1147 | + ], |
1140 | 1148 | config=True,
|
1141 | 1149 | help=_('The content manager class to use.')
|
1142 | 1150 | )
|
1143 | 1151 |
|
| 1152 | + # Throws a deprecation warning to notebook based contents managers. |
| 1153 | + @observe('contents_manager_class') |
| 1154 | + def _observe_contents_manager_class(self, change): |
| 1155 | + new = change['new'] |
| 1156 | + # If 'new' is a class, get a string representing the import |
| 1157 | + # module path. |
| 1158 | + if inspect.isclass(new): |
| 1159 | + new = new.__module__ |
| 1160 | + |
| 1161 | + if new.startswith('notebook'): |
| 1162 | + self.log.warning( |
| 1163 | + "The specified 'contents_manager_class' class inherits a manager from the " |
| 1164 | + "'notebook' package. This is not guaranteed to work in future " |
| 1165 | + "releases of Jupyter Server. Instead, consider switching the " |
| 1166 | + "manager to inherit from the 'jupyter_server' managers. " |
| 1167 | + "Jupyter Server will temporarily allow 'notebook' managers " |
| 1168 | + "until its next major release (2.x)." |
| 1169 | + ) |
| 1170 | + |
| 1171 | + @observe('notebook_dir') |
| 1172 | + def _update_notebook_dir(self, change): |
| 1173 | + self.log.warning(_("notebook_dir is deprecated, use root_dir")) |
| 1174 | + self.root_dir = change['new'] |
| 1175 | + |
1144 | 1176 | kernel_manager_class = Type(
|
1145 | 1177 | default_value=MappingKernelManager,
|
1146 | 1178 | config=True,
|
|
0 commit comments