Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass in overridable options to child spawners #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion wrapspawner/wrapspawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ def _options_form_default(self):

def options_from_form(self, formdata):
# Default to first profile if somehow none is provided
opts = formdata.copy()
if 'profile' in opts: del opts['profile']
for opt in opts:
val = opts.get(opt, [''])
opts[opt]=val[0]
if len(opts)>0:
self.child_config=opts
else:
self.child_config={}
return dict(profile=formdata.get('profile', [self.profiles[0][1]])[0])

# load/get/clear : save/restore child_profile (and on load, use it to update child class/config)
Expand All @@ -186,7 +195,7 @@ def select_profile(self, profile):
for p in self.profiles:
if p[1] == profile:
self.child_class = p[2]
self.child_config = p[3]
self.child_config.update(p[3])
break

def construct_child(self):
Expand Down