Skip to content

Commit

Permalink
Use subclasses to expose types of servers
Browse files Browse the repository at this point in the history
These changes break the existing ServerApp into 3 subclasses of
BaseServerApp - ServerApp (for serving notebooks), KernelServerApp
(for serving kernels) and ContentsServerApp (for serving content).

This approach allows for more specific behaviors in the various
subclasses, but, I suspect, breaks the ExtensionApp modeling, since
that appears to assume extensions are applied to ServerApp.  As a
result, more investigation is required if we wanted KernelServerApp
or ContentsServerApp to have the ability to be extended, rather than
only subclassed.

All tests currently pass against ServerApp, and KernelServerApp appears
to startup fine and only serve the application endpoints.
  • Loading branch information
kevin-bates committed Feb 3, 2020
1 parent 7a6cd8e commit 64f2378
Show file tree
Hide file tree
Showing 3 changed files with 296 additions and 159 deletions.
10 changes: 5 additions & 5 deletions jupyter_server/extension/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

from jupyter_core.application import JupyterApp

from jupyter_server.serverapp import ServerApp, aliases, flags
from jupyter_server.serverapp import ServerApp
from jupyter_server.transutils import _
from jupyter_server.utils import url_path_join
from .handler import ExtensionHandler

# Remove alias for nested classes in ServerApp.
# Nested classes are not allowed in ExtensionApp.
try:
aliases.pop('transport')
ServerApp.aliases.pop('transport')
except KeyError:
pass

Expand Down Expand Up @@ -124,7 +124,7 @@ def _prepare_templates(self):
# Aliases and Flags
#-----------------------------------------------------------------------------

flags['no-browser']=(
ServerApp.flags['no-browser']=(
{'ExtensionApp' : {'open_browser' : True}},
_("Prevent the opening of the default url in the browser.")
)
Expand Down Expand Up @@ -181,8 +181,8 @@ def _validate_extension_name(self, proposal):
ServerApp,
]

aliases = aliases
flags = flags
aliases = ServerApp.aliases
flags = ServerApp.flags

subcommands = {}

Expand Down
Loading

0 comments on commit 64f2378

Please sign in to comment.