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