give Spawners, Authenticators db access

as self.db
This commit is contained in:
Min RK
2015-01-16 16:33:46 -08:00
parent c4eb233631
commit 8cd2a55aa8
5 changed files with 7 additions and 4 deletions

View File

@@ -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:

View File

@@ -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.

View File

@@ -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()

View File

@@ -37,6 +37,7 @@ class Spawner(LoggingConfigurable):
- poll
"""
db = Any()
user = Any()
hub = Any()
api_token = Unicode()

View File

@@ -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):