Hey Scott,
you’re raising a good point, I’m not sure that the order of these is well specified and we’re relying on hope a bit that nobody will ever submit more than one of these query arguments. Perhaps we need a little helper function like this:
def single_arg(name, default=None):
vals = request.args.getlist(name)
vals = [v for v in vals if len(v.strip())]
if len(vals) == 0:
return default
if len(vals) > 1:
raise BadRequest(“Too many values given for: %s” % name)
return vals[0]
Cheers,
- Friedrich
Hi Friedrich,
I am wondering what the expected behavior would be if someone passes in multiple values with the same key. It looks like the way this is implemented, it would only filter for the "first" value for that key. Also, looking at the Flask docs, it is not clear to me whether first here is well defined -- that is I'm not sure that it would necessarily be the first instance in the query string.
Just wanted to point this out and wondering if you want me to do a similar implementation for the all_entities function.
Thanks!
Scott