flickyou
I began writing this library months ago because I needed it in a project. At that time there was a bunch of libraries all quite useless for us. One didn’t really work, another didn’t support authentication, another was incomplete so I started this library that, in the end, we didn’t use because Flickr ceased to be a requirement for the project.
The name is flickyou because I think Flickr has one of the worst API out there and their maniacal obsession with control is a little insane, so you can easily guess what lies behind the name
After “throwing” a bunch of code in the wild I soon realized that some kind of design was emerging and although I still think it’s not perfect I tried to separate as much as possible the various aspects of the library. Let’s see them:
Main class: FlickrClient
This is the “entry point” of the whole library. Instantiate it and start calling the Flickr API and use the response.
This class requires only the two keys Flickr issues to its users.
By default the library uses the JSON response format so you’ll need simplejson as its only requirement.
If you take a look at its implementation you’ll notice that the actual machinery is done in a separate “backend” class.
The trick to activate that machinery is in the __ getattr __ method: it first looks for a real implementation of the method (so you can easily extend the backend), then if nothing comes out it issues a request to the Flickr server directly.
This way I didn’t have to code an implementation of each and every method the API supports.
Abstract backend: BaseBackend
This class is the specification for the machinery. Its documentation explains how it has to be extended and provides a partial implementation of the overall process (like the photo upload support which works outside the Flickr API).
If you don’t want to extend the library with other request/response formats or something I can’t know you don’t need to care about this class.
Default backend: JSONBackend
The Flickr API allows to specify some response formats: JSON, XML (REST), XML (XML-RPC), XML (SOAP) and a custom PHP serialized format.
You can also call the API through HTTP (REST), XML-RPC and SOAP.
Not every combination makes sense: you can’t issue a request with XML-RPC and request to get JSON in response. Ok in theory you can, but in practice xmlrpclib will obviously complain so as I said, not every combination makes sense.
I decided to go with HTTP for the requests and JSON for the response format as the default.
JSONBackend is a very simple class: creates the API signature, issues the HTTP POST request, reads the response, parses it with simplejson and checks for errors.
It provides an actual implementation for the three fundamental methods: checkToken, getFrob, getToken.
JSONBackend also stores the token in a cache on the file system.
That’s basically all about the rationale of the library.
Where to find flickyou
- Homepage: http://code.google.com/p/flickyou/
- Download: http://code.google.com/p/flickyou/downloads/list
- Cheeseshop page: http://pypi.python.org/pypi/flickyou/
- Usage documentation: http://code.google.com/p/flickyou/wiki/Usage
- SVN repository: http://svn.oluyede.org/projects/flickyou/trunk/
- Trac page: http://dev.oluyede.org/trac/default/browser/flickyou/trunk

