sybrenstuvel / flickrapi

Python Flickr API implementation
https://stuvel.eu/flickrapi
Other
155 stars 33 forks source link

walk_set error #80

Closed greenpasta closed 7 years ago

greenpasta commented 7 years ago

I'm on Python 3.4.5 and the following code:

flickr = flickrapi.FlickrAPI(my_api_key, my_secret_key, format='parsed-json')
photoset = flickr.walk_set('72157640799982165') 

Gives this error:

File "/usr/local/venv/myvenv/lib/python3.4/site-packages/flickrapi/core.py", line 96, in decorated
    raise ValueError(msg % (method.func_name, self.default_format))
AttributeError: 'function' object has no attribute 'func_name'
sybrenstuvel commented 7 years ago

Good find. We should be using method.__name__ instead of method.func_name. Can you change the code and see if that solves things?

greenpasta commented 7 years ago

It does clear that error, but now gives me an issue with using parsed-json as the format. While I would prefer JSON, it's not the end of the world for me to use etree.

  File "/usr/local/venv/myvenv/lib/python3.4/site-packages/flickrapi/core.py", line 96, in decorated
    raise ValueError(msg % (method.__name__, self.default_format))
ValueError: Function walk_set requires that you use ElementTree ("etree") as the communication format, while the current format is set to "parsed-json".
sybrenstuvel commented 7 years ago

This is documented ("Uses the ElementTree format, incompatible with other formats."), but I understand your fondness of JSON. As an alternative to switching your entire application to ElementTree, you could also extend FlickrAPI.data_walker() so that it also supports JSON. If you do that, I'd suggest renaming the current function to _data_walker_etree() and adding a _data_walker_json(), and then turning data_walker() into a function that calls either one of those depending on the configured format.

If you do this, please send it in as a pull request so that I can merge it into the FlickrAPI library.

sybrenstuvel commented 7 years ago

Closing this ticket as the actual bug is fixed. Feel free to send in a pull request for JSON support in the walker functions.