mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Merge pull request #3158 from shiti-saxena/dev
adding option to specify extra services
This commit is contained in:
commit
27c00bfb20
@ -134,7 +134,6 @@ def random_ports(port, n):
|
|||||||
|
|
||||||
def load_handlers(name):
|
def load_handlers(name):
|
||||||
"""Load the (URL pattern, handler) tuples for each component."""
|
"""Load the (URL pattern, handler) tuples for each component."""
|
||||||
name = 'notebook.' + name
|
|
||||||
mod = __import__(name, fromlist=['default_handlers'])
|
mod = __import__(name, fromlist=['default_handlers'])
|
||||||
return mod.default_handlers
|
return mod.default_handlers
|
||||||
|
|
||||||
@ -146,21 +145,22 @@ class NotebookWebApplication(web.Application):
|
|||||||
|
|
||||||
def __init__(self, jupyter_app, kernel_manager, contents_manager,
|
def __init__(self, jupyter_app, kernel_manager, contents_manager,
|
||||||
session_manager, kernel_spec_manager,
|
session_manager, kernel_spec_manager,
|
||||||
config_manager, log,
|
config_manager, extra_services, log,
|
||||||
base_url, default_url, settings_overrides, jinja_env_options):
|
base_url, default_url, settings_overrides, jinja_env_options):
|
||||||
|
|
||||||
|
|
||||||
settings = self.init_settings(
|
settings = self.init_settings(
|
||||||
jupyter_app, kernel_manager, contents_manager,
|
jupyter_app, kernel_manager, contents_manager,
|
||||||
session_manager, kernel_spec_manager, config_manager, log,
|
session_manager, kernel_spec_manager, config_manager,
|
||||||
base_url, default_url, settings_overrides, jinja_env_options)
|
extra_services, log, base_url,
|
||||||
|
default_url, settings_overrides, jinja_env_options)
|
||||||
handlers = self.init_handlers(settings)
|
handlers = self.init_handlers(settings)
|
||||||
|
|
||||||
super(NotebookWebApplication, self).__init__(handlers, **settings)
|
super(NotebookWebApplication, self).__init__(handlers, **settings)
|
||||||
|
|
||||||
def init_settings(self, jupyter_app, kernel_manager, contents_manager,
|
def init_settings(self, jupyter_app, kernel_manager, contents_manager,
|
||||||
session_manager, kernel_spec_manager,
|
session_manager, kernel_spec_manager,
|
||||||
config_manager,
|
config_manager, extra_services,
|
||||||
log, base_url, default_url, settings_overrides,
|
log, base_url, default_url, settings_overrides,
|
||||||
jinja_env_options=None):
|
jinja_env_options=None):
|
||||||
|
|
||||||
@ -259,6 +259,9 @@ class NotebookWebApplication(web.Application):
|
|||||||
kernel_spec_manager=kernel_spec_manager,
|
kernel_spec_manager=kernel_spec_manager,
|
||||||
config_manager=config_manager,
|
config_manager=config_manager,
|
||||||
|
|
||||||
|
# handlers
|
||||||
|
extra_services=extra_services,
|
||||||
|
|
||||||
# Jupyter stuff
|
# Jupyter stuff
|
||||||
started=now,
|
started=now,
|
||||||
jinja_template_vars=jupyter_app.jinja_template_vars,
|
jinja_template_vars=jupyter_app.jinja_template_vars,
|
||||||
@ -283,25 +286,28 @@ class NotebookWebApplication(web.Application):
|
|||||||
|
|
||||||
# Order matters. The first handler to match the URL will handle the request.
|
# Order matters. The first handler to match the URL will handle the request.
|
||||||
handlers = []
|
handlers = []
|
||||||
handlers.extend(load_handlers('tree.handlers'))
|
# load extra services specified by users before default handlers
|
||||||
|
for service in settings['extra_services']:
|
||||||
|
handlers.extend(load_handlers(service))
|
||||||
|
handlers.extend(load_handlers('notebook.tree.handlers'))
|
||||||
handlers.extend([(r"/login", settings['login_handler_class'])])
|
handlers.extend([(r"/login", settings['login_handler_class'])])
|
||||||
handlers.extend([(r"/logout", settings['logout_handler_class'])])
|
handlers.extend([(r"/logout", settings['logout_handler_class'])])
|
||||||
handlers.extend(load_handlers('files.handlers'))
|
handlers.extend(load_handlers('notebook.files.handlers'))
|
||||||
handlers.extend(load_handlers('view.handlers'))
|
handlers.extend(load_handlers('notebook.view.handlers'))
|
||||||
handlers.extend(load_handlers('notebook.handlers'))
|
handlers.extend(load_handlers('notebook.notebook.handlers'))
|
||||||
handlers.extend(load_handlers('nbconvert.handlers'))
|
handlers.extend(load_handlers('notebook.nbconvert.handlers'))
|
||||||
handlers.extend(load_handlers('bundler.handlers'))
|
handlers.extend(load_handlers('notebook.bundler.handlers'))
|
||||||
handlers.extend(load_handlers('kernelspecs.handlers'))
|
handlers.extend(load_handlers('notebook.kernelspecs.handlers'))
|
||||||
handlers.extend(load_handlers('edit.handlers'))
|
handlers.extend(load_handlers('notebook.edit.handlers'))
|
||||||
handlers.extend(load_handlers('services.api.handlers'))
|
handlers.extend(load_handlers('notebook.services.api.handlers'))
|
||||||
handlers.extend(load_handlers('services.config.handlers'))
|
handlers.extend(load_handlers('notebook.services.config.handlers'))
|
||||||
handlers.extend(load_handlers('services.kernels.handlers'))
|
handlers.extend(load_handlers('notebook.services.kernels.handlers'))
|
||||||
handlers.extend(load_handlers('services.contents.handlers'))
|
handlers.extend(load_handlers('notebook.services.contents.handlers'))
|
||||||
handlers.extend(load_handlers('services.sessions.handlers'))
|
handlers.extend(load_handlers('notebook.services.sessions.handlers'))
|
||||||
handlers.extend(load_handlers('services.nbconvert.handlers'))
|
handlers.extend(load_handlers('notebook.services.nbconvert.handlers'))
|
||||||
handlers.extend(load_handlers('services.kernelspecs.handlers'))
|
handlers.extend(load_handlers('notebook.services.kernelspecs.handlers'))
|
||||||
handlers.extend(load_handlers('services.security.handlers'))
|
handlers.extend(load_handlers('notebook.services.security.handlers'))
|
||||||
handlers.extend(load_handlers('services.shutdown'))
|
handlers.extend(load_handlers('notebook.services.shutdown'))
|
||||||
handlers.extend(settings['contents_manager'].get_extra_handlers())
|
handlers.extend(settings['contents_manager'].get_extra_handlers())
|
||||||
|
|
||||||
handlers.append(
|
handlers.append(
|
||||||
@ -317,7 +323,7 @@ class NotebookWebApplication(web.Application):
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
# register base handlers last
|
# register base handlers last
|
||||||
handlers.extend(load_handlers('base.handlers'))
|
handlers.extend(load_handlers('notebook.base.handlers'))
|
||||||
# set the URL that will be redirected from `/`
|
# set the URL that will be redirected from `/`
|
||||||
handlers.append(
|
handlers.append(
|
||||||
(r'/?', RedirectWithParams, {
|
(r'/?', RedirectWithParams, {
|
||||||
@ -954,6 +960,10 @@ class NotebookApp(JupyterApp):
|
|||||||
help=_("""extra paths to look for Javascript notebook extensions""")
|
help=_("""extra paths to look for Javascript notebook extensions""")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
extra_services = List(Unicode(), config=True,
|
||||||
|
help=_("""handlers that should be loaded at higher priority than the default services""")
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def nbextensions_path(self):
|
def nbextensions_path(self):
|
||||||
"""The path to look for Javascript notebook extensions"""
|
"""The path to look for Javascript notebook extensions"""
|
||||||
@ -1255,7 +1265,7 @@ class NotebookApp(JupyterApp):
|
|||||||
self.web_app = NotebookWebApplication(
|
self.web_app = NotebookWebApplication(
|
||||||
self, self.kernel_manager, self.contents_manager,
|
self, self.kernel_manager, self.contents_manager,
|
||||||
self.session_manager, self.kernel_spec_manager,
|
self.session_manager, self.kernel_spec_manager,
|
||||||
self.config_manager,
|
self.config_manager, self.extra_services,
|
||||||
self.log, self.base_url, self.default_url, self.tornado_settings,
|
self.log, self.base_url, self.default_url, self.tornado_settings,
|
||||||
self.jinja_environment_options
|
self.jinja_environment_options
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user