Re:

6 views
Skip to first unread message

Friedrich Lindenberg

unread,
Jun 12, 2014, 1:31:08 AM6/12/14
to scott....@northwestern.edu, Manuel Aristaran, gran...@googlegroups.com
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 

On 11 Jun 2014, at 23:33, Scott Bradley <scott....@northwestern.edu> wrote:

Hi Friedrich,

Can I get a clarification regarding args handling, re: filter_query https://github.com/granoproject/grano/blob/master/grano/views/util.py#L29

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

signature.asc
Reply all
Reply to author
Forward
0 new messages