Skip to content

Commit e78e4bf

Browse files
authored
Merge pull request #400 from minrk/root-dir-priority
only use deprecated notebook_dir config if root_dir is not set
2 parents 5013f62 + 5a28ec1 commit e78e4bf

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

jupyter_server/serverapp.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,16 +1264,22 @@ def _update_pylab(self, change):
12641264

12651265
@observe('notebook_dir')
12661266
def _update_notebook_dir(self, change):
1267+
if self._root_dir_set:
1268+
# only use deprecated config if new config is not set
1269+
return
12671270
self.log.warning(_("notebook_dir is deprecated, use root_dir"))
12681271
self.root_dir = change['new']
12691272

1270-
root_dir = Unicode(config=True,
1273+
root_dir = Unicode(
1274+
config=True,
12711275
help=_("The directory to use for notebooks and kernels.")
12721276
)
1277+
_root_dir_set = False
12731278

12741279
@default('root_dir')
12751280
def _default_root_dir(self):
12761281
if self.file_to_run:
1282+
self._root_dir_set = True
12771283
return os.path.dirname(os.path.abspath(self.file_to_run))
12781284
else:
12791285
return py3compat.getcwd()
@@ -1294,6 +1300,10 @@ def _root_dir_validate(self, proposal):
12941300
raise TraitError(trans.gettext("No such notebook dir: '%r'") % value)
12951301
return value
12961302

1303+
@observe('root_dir')
1304+
def _root_dir_changed(self, change):
1305+
self._root_dir_set = True
1306+
12971307
@observe('server_extensions')
12981308
def _update_server_extensions(self, change):
12991309
self.log.warning(_("server_extensions is deprecated, use jpserver_extensions"))

0 commit comments

Comments
 (0)