Flickr.API 0.4.3
Aaron kindly informed me of a problem with Flickr.API where calling flickr.urls.lookupUser with the required 'url' parameter returns the the contents of the resource pointed to by that url, instead of the expected API response. The problem is easily demonstrated using flickrcall.py, introduced in this post:
The trouble lies in the Flickr.API.Request init:
Clearly I didn't anticipate 'url' as a valid argument - if you pass it in through **args it overwrites the default url parameter. Worse, if you wanted to use a different api endpoint, you couldn't even call this method with the required url parameter as python will complain about multiple values for the same 'url' argument. Here's a simple demonstration of what's happening:
For 0.4.3, I've simply changed the url keyword parameter to apiurl to make things work as I haven't thought of any backwards compatible way to fix this. Now we get the right response:
I'm hoping that unless you work at Flickr (we're hiring!), you're not likely to change the endpoint url and this change should only fix this particular problem for you.
$ flickrcall.py flickr.urls.lookupUser "url=http://www.flickr.com/photos/graph" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> ...
def __init__(self, url='http://api.flickr.com/services/rest/', **args): urllib2.Request.__init__(self, url=url) ...
>>> def foo(bar="baz", **kwargs): print bar >>> foo() baz >>> foo("bar") bar >>> foo(bar="bar") bar >>> foo(**{"bar":"bar"}) bar >>> foo("bar", **{"bar":"baz"}) TypeError: foo() got multiple values for keyword argument 'bar' >>> foo(bar="bar", **{"bar":"baz"}) TypeError: foo() got multiple values for keyword argument 'bar'
$ flickrcall.py flickr.urls.lookupUser "url=http://www.flickr.com/photos/graph" <?xml version="1.0" encoding="utf-8" ?> <rsp stat="ok"> <user id="83127823@N00"> <username>raphco</username> </user> </rsp>
