Hi Ben, thanks for your mail.

Yea, after digging into the code I see there is not currently a way to 
do this, or perform queries with nested keys, such as:

/query.json?query={"type": "/type/edition", "table_of_contents": 
{"pagenum": 19}}

I would like to do something like 
/query.json?type=/type/edition&table_of_contents.pagenum=19

I submitted a patch, but it is a hack: 
https://github.com/internetarchive/infogami/pull/2

Looking into it more I see web.py retrieves the query parameters via 
'FieldStorage' from python's cgi.py, which parses the query string with 
'parse_qsl' from urlparse.py. So by the time web.py gets the parameters, 
they've already been decoded by 'parse_qsl', making it difficult to do 
additional parsing...

But, one could monkey-patch urlparse with a custom parser -- I've been 
experimenting with this just now and it seems like it could work out 
alright, though it is still a bit of a hack.

Any thoughts on syntax, supposing I did try this?

multi-value:

     &subjects=war,peace
     &subjects=[war,peace]
     &subjects=war+OR+peace


nesting:

     &table_of_contents.pagenum=19 (I reckon this is the most natural 
looking, but since . is unreserved it might cause trouble)
     &table_of_contents:pagenum=19
     &table_of_contents::pagenum=19


--
tom




On 07/30/2013 05:27 PM, Ben Companjen wrote:
> Hi Tom,
>
> As you probably discovered, I don't think so (at least, when I tried
> some time ago, it didn't work either). I think commas can be included
> in terms themselves, as can any(?) other character. That makes it
> hard(er) to designate a separator character.
> There is a small chance that I'm wrong, because I'm not too familiar
> with details in the code.
>
> Regards,
>
> Ben
>
> On 26 July 2013 06:34, Tom Kerr <[email protected]> wrote:
>> One is able to perform multi-value queries when passing a JSON
>> dictionary, like:
>>
>> http://openlibrary.org/query.json?query={"type": "/type/work",
>> "subjects": ["war", "peace"]}
>>
>> but is there a way to do this without the JSON? Something like:
>>
>>    http://openlibrary.org/query.json?type=/type/work&subjects=war,peace
>>
>> Tom
>> _______________________________________________
>> Ol-tech mailing list
>> [email protected]
>> http://mail.archive.org/cgi-bin/mailman/listinfo/ol-tech
>> To unsubscribe from this mailing list, send email to 
>> [email protected]
> _______________________________________________
> Ol-tech mailing list
> [email protected]
> http://mail.archive.org/cgi-bin/mailman/listinfo/ol-tech
> To unsubscribe from this mailing list, send email to 
> [email protected]
>

_______________________________________________
Ol-tech mailing list
[email protected]
http://mail.archive.org/cgi-bin/mailman/listinfo/ol-tech
To unsubscribe from this mailing list, send email to 
[email protected]

Reply via email to