Skip to content

Commit

Permalink
Make it easier for extensions to customize the ServerApp (#879)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Silvester <[email protected]>
Co-authored-by: Zachary Sailer <[email protected]>
  • Loading branch information
3 people authored Jul 7, 2022
1 parent 6fea5d8 commit 204a004
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion jupyter_server/extension/application.py
Original file line number Diff line number Diff line change
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

0 comments on commit 204a004

Please sign in to comment.