mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 22:43:00 +00:00
give Spawners, Authenticators db access
as self.db
This commit is contained in:
@@ -287,7 +287,7 @@ class JupyterHub(Application):
|
||||
|
||||
authenticator = Instance(Authenticator)
|
||||
def _authenticator_default(self):
|
||||
return self.authenticator_class(config=self.config)
|
||||
return self.authenticator_class(parent=self, db=self.db)
|
||||
|
||||
# class for spawning single-user servers
|
||||
spawner_class = Type(LocalProcessSpawner, Spawner,
|
||||
@@ -577,7 +577,7 @@ class JupyterHub(Application):
|
||||
continue
|
||||
self.log.debug("Loading state for %s from db", user.name)
|
||||
user.spawner = spawner = self.spawner_class(
|
||||
user=user, hub=self.hub, config=self.config,
|
||||
user=user, hub=self.hub, config=self.config, db=self.db,
|
||||
)
|
||||
status = yield spawner.poll()
|
||||
if status is None:
|
||||
|
@@ -10,7 +10,7 @@ from tornado import gen
|
||||
import simplepam
|
||||
|
||||
from IPython.config import LoggingConfigurable
|
||||
from IPython.utils.traitlets import Bool, Set, Unicode
|
||||
from IPython.utils.traitlets import Bool, Set, Unicode, Any
|
||||
|
||||
from .handlers.login import LoginHandler
|
||||
from .utils import url_path_join
|
||||
@@ -21,6 +21,7 @@ class Authenticator(LoggingConfigurable):
|
||||
The API is one method, `authenticate`, a tornado gen.coroutine.
|
||||
"""
|
||||
|
||||
db = Any()
|
||||
whitelist = Set(config=True,
|
||||
help="""Username whitelist.
|
||||
|
||||
|
@@ -306,6 +306,7 @@ class User(Base):
|
||||
config=config,
|
||||
user=self,
|
||||
hub=hub,
|
||||
db=db,
|
||||
)
|
||||
# we are starting a new server, make sure it doesn't restore state
|
||||
spawner.clear_state()
|
||||
|
@@ -37,6 +37,7 @@ class Spawner(LoggingConfigurable):
|
||||
- poll
|
||||
"""
|
||||
|
||||
db = Any()
|
||||
user = Any()
|
||||
hub = Any()
|
||||
api_token = Unicode()
|
||||
|
@@ -39,7 +39,7 @@ def new_spawner(db, **kwargs):
|
||||
kwargs.setdefault('INTERRUPT_TIMEOUT', 1)
|
||||
kwargs.setdefault('TERM_TIMEOUT', 1)
|
||||
kwargs.setdefault('KILL_TIMEOUT', 1)
|
||||
return LocalProcessSpawner(**kwargs)
|
||||
return LocalProcessSpawner(db=db, **kwargs)
|
||||
|
||||
|
||||
def test_spawner(db, io_loop):
|
||||
|
Reference in New Issue
Block a user