edsu / opensearch

A python opensearch client
http://python.org/pypi/opensearch
GNU General Public License v3.0
44 stars 14 forks source link

Not working with VIAF #1

Closed rubinsztajn closed 13 years ago

rubinsztajn commented 14 years ago

This is a lovely little open search client, thanks! I've had some issues getting it to work with VIAF, however. It looks like their description file is out of date so I have an updated one here: http://people.umass.edu/arubinst/allFieldsSearch.xml. I've tested this in my browser and it works as expected. VIAF's url format seems to choke opensearch:

 >>> client = Client('http://people.umass.edu/arubinst/allFieldsSearch.xml')    
 >>> q = Query(client.description.get_best_template())
 >>> q.query_string
 {u'sortKeys': [u'holdingscount'], u'query': [u'cql.any all"{searchTerms}"'], u'stylesheet':  [u'xsl/results.xsl'], u'maximumRecords': [u'100'], u'http:accept': [u'application/rss+xml']}

As you can see, q.query_string['query'] includes VIAF's wacky opensearch parameters, which plays havoc with line 40 of query.py:

macro = values[0].replace('{','').replace('}','').replace('?','')

FWIW, it looks like VIAF's template url is kosher according to the open search spec.

Again, thanks for the great client!

Aaron Rubinstein

rubinsztajn commented 14 years ago

oops, I blamed the havoc on the wrong line... Try line 41: if macro in Query.standard_macros: self.macro_map[macro] = key Sorry!

edsu commented 14 years ago

Is the original oclc opensearch description file here?

http://viaf.org/allFieldsSearch.xml

It's extremely sad to me that a client can't autodiscover the opensearch description, since they don't appear to be serving up HTML, but some complicated XSL soup :-(

http://opensearchvalidator.com/validate?p=http://viaf.org/&st=tolkien

rubinsztajn commented 14 years ago

Yes, that's it...

I'll join you in a cry... My fear is that they've abandoned opensearch for the SRU interface.

edsu commented 14 years ago

Thanks for pointing this out Aaron. I think the opensearch library will need a bit of work before it can work w/ this kind of Query template. But I think you are right that essentially your modified template is ok. Mark Matienzo over in cod4lib irc just noticed that you might have a missing + in your template, which would cause VIAF to choke on the query. Shouldn't you have: "?query=cql.any+all+%22..."

rubinsztajn commented 14 years ago

Absolutely. Thanks for pointing that out, Mark! Let me know if there's anything I can do to help with the library. If you want, I can work on a patch for this particular problem.