Last active
November 30, 2016 17:11
-
-
Save Fedjmike/fccf9940e2c661b7941c96dd5c297cf0 to your computer and use it in GitHub Desktop.
with_request_values_positionally
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@decorator_with_args | |
def with_request_values_positionally(view, keys=[], optional_keys=[], | |
error_view=request_by_json_missing_value): | |
try: | |
values = [request.values[key] for key in keys] | |
#Only catch a KeyError from that particular lookup, not the whole view function | |
except KeyError: | |
return error_view() | |
#None if not present | |
optional_values = dict_values(request.values, keys) | |
return view(*values) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment