eliminate argument duplication
In many places (especially the scan extension), we end up duplicating argument lists in many places - in a schema, in a MethodView
subclass's methods, and in an extension method that actually does the action. This is verbose and unhelpful, and is a recipe for errors creeping in to the code. After much discussion, including with @jtc42, we will move towards a cleaner, decorator-based way of converting functions that do something into action
affordances and hence into HTTP response handlers.
It would also be beneficial to make some of the functions take nested dictionaries as arguments - e.g. if we want to run a scan that captures images, we should put the arguments that are passed to the capture function in a sub-dictionary, rather than merging the keys and values at the top level. That means we'd go from something that looks like:
{
"quality": 100,
"filname": "whatever.jpg",
"bayer": false,
"scan_points": [10,10,9],
"scan_step": [800,600,10]
}
to something that looks more like:
{
"capture_params": {
"quality": 100,
"filname": "whatever.jpg",
"bayer": false
},
"scan_params": {
"scan_points": [10,10,9],
"scan_step": [800,600,10]
}
}
This is just as easy to describe with nested schemas, but makes it immediately clear which argument goes where, and makes it much easier, cleaner, and safer to just pull out a dictionary of options and pass it on to the relevant function.
This will be a breaking API change, so is slated for v3.