-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a separate script for the hub app
- Loading branch information
1 parent
a93cebc
commit b78164f
Showing
5 changed files
with
35 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from jupyterhub.singleuser.mixins import make_singleuser_app | ||
from jupyter_server.serverapp import ServerApp | ||
from .app import GalleryApp | ||
|
||
|
||
class classproperty(property): | ||
def __get__(self, owner_self, owner_cls): | ||
return self.fget(owner_cls) | ||
|
||
|
||
class HubGalleryApp(GalleryApp): | ||
# This is in a separate file because traitlets metaclass | ||
# will read from each property on start, including serverapp_class, | ||
# which will have side effects for the server if run outside of juypterhub | ||
|
||
@classproperty | ||
def serverapp_class(cls): | ||
"""If jupyterhub is installed, apply the jupyterhub patches, | ||
but only do this when this property is accessed, which is when | ||
the gallery is used as a standalone app. | ||
""" | ||
|
||
if cls._server_cls is None: | ||
cls._server_cls = make_singleuser_app(ServerApp) | ||
return cls._server_cls | ||
|
||
_server_cls = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters