MOE
MOE copied to clipboard
[Python] Use colander schema binding to create colander components dynamically
At the moment,
e.g., OptimizableGpPrettyView.get_params_from_request
is a hacky mess that bypasses colander almost entirely. It reads user input from raw json, pulls a default value, and then overwrites defaults with user input when user input is available. That's what colander is supposed to do for us.
Colander provides "schema binding" via colander.deferred
that (i THINK) does exactly what we ant.
basic ex here: http://stackoverflow.com/questions/10567286/defining-missing-for-colander-schemanode-dynamically colander details: http://docs.pylonsproject.org/projects/colander/en/latest/binding.html but it appears that we can use schema binding to create deferred schemanodes, deferred validators, deferred missing fields, and more. So it'd be cool to be able use deferred components to decide how to deserialize optimization objects instead of the hacky mess we have now.
There are probably other places where we'd like to make dynamic colander decisions as well.