racker/falcon — pull request #336 by xiaclo (2014-10-11 01:31:54+00:00)
Title: Store blank parameters as '' instead of None

I know this was a recent change, but I think it makes more sense to have a way to differentiate between a parameter that has no value and a parameter that wasn't present. It basically changes things the way the keep_blank_values parameter works in urlparse.parse_qs.

This change WILL break a lot of tests, including the list tests with empty elements. I would be happy to update tests, but I want some feedback on what is preferred. The easier solution would be a parameter to parse_query_string, but I'm not sure how this would be passed into the request (maybe an environment variable?). Another alternative would be adding a parameter to request.get_param and request.get_param_as_list which will filter after the fact, but it would be less efficient.

There is more edge cases like request.get_param_as_list(transform=int) with empty elements. It currently raises InvalidParam, is this the "correct" behaviour? Should request.get_param_as_list(transform=float) raise InvalidParam or return empty elements as float('nan')? Maybe both these cases should return None elements instead.

I realize this change is trading flexibility for performance, and it may be rejected for this reason. If you think it's useful though, I would be happy to update the test suites and make sure everything is working.