Address review in named_servers

from willingc

- consistency of repr/str when logging usernames
- cleanup some attribute declarations
- add comments about db session weirdness
This commit is contained in:
Min RK
2017-07-26 10:47:35 +02:00
parent 194d6c9d4c
commit 3e796b579d
4 changed files with 16 additions and 14 deletions

View File

@@ -88,6 +88,7 @@ class User(HasTraits):
def _log_default(self):
return app_log
spawners = None
settings = Dict()
db = Any(allow_none=True)
@@ -103,7 +104,10 @@ class User(HasTraits):
# db session changed, re-get orm User
db = change.new
if self._user_id is not None:
# fetch our orm.User from the new db session
self.orm_user = db.query(orm.User).filter(orm.User.id == self._user_id).first()
# update our spawners' ORM objects with the new session,
# which can be found on our new orm_user.
for name, spawner in self.spawners.items():
spawner.orm_spawner = self.orm_user.orm_spawners[name]
@@ -116,8 +120,6 @@ class User(HasTraits):
else:
self._user_id = None
spawners = None
@property
def authenticator(self):
return self.settings.get('authenticator', None)