persist user_options

remember user_options from the previous run

this allows user options set via spawn form to be re-used when restarting e.g. a named server via the api
This commit is contained in:
Min RK
2019-02-28 14:27:47 +01:00
parent 25aa892f86
commit ddc852d658
4 changed files with 87 additions and 1 deletions

View File

@@ -479,8 +479,17 @@ class User:
# pass requesting handler to the spawner
# e.g. for processing GET params
spawner.handler = handler
# Passing user_options to the spawner
spawner.user_options = options or {}
if options is None:
# options unspecified, load from db which should have the previous value
options = spawner.orm_spawner.user_options or {}
else:
# options specified, save for use as future defaults
spawner.orm_spawner.user_options = options
db.commit()
spawner.user_options = options
# we are starting a new server, make sure it doesn't restore state
spawner.clear_state()