Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier for extensions to customize the ServerApp #879

Merged
merged 3 commits into from
Jul 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions jupyter_server/extension/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from jupyter_core.application import JupyterApp, NoStart
from tornado.log import LogFormatter
from tornado.web import RedirectHandler
from traitlets import Any, Bool, Dict, HasTraits, List, Unicode, default
from traitlets import Any, Bool, Dict, HasTraits, List, Type, Unicode, default
blink1073 marked this conversation as resolved.
Show resolved Hide resolved
from traitlets.config import Config

from jupyter_server.serverapp import ServerApp
Expand Down Expand Up @@ -538,6 +538,16 @@ def load_classic_server_extension(cls, serverapp):
)
extension.initialize()

serverapp_class = ServerApp

@classmethod
def make_serverapp(cls, **kwargs):
"""Instantiate the ServerApp

Override to customize the ServerApp before it loads any configuration
"""
return cls.serverapp_class.instance(**kwargs)

@classmethod
def initialize_server(cls, argv=None, load_other_extensions=True, **kwargs):
"""Creates an instance of ServerApp and explicitly sets
Expand All @@ -553,7 +563,7 @@ def initialize_server(cls, argv=None, load_other_extensions=True, **kwargs):
jpserver_extensions.update(cls.serverapp_config["jpserver_extensions"])
cls.serverapp_config["jpserver_extensions"] = jpserver_extensions
find_extensions = False
serverapp = ServerApp.instance(jpserver_extensions=jpserver_extensions, **kwargs)
serverapp = cls.make_serverapp(jpserver_extensions=jpserver_extensions, **kwargs)
serverapp.aliases.update(cls.aliases)
serverapp.initialize(
argv=argv or [],
Expand Down