Module e.p.f.flickr_api

Part of elisa.plugins.flickr

Constants and helper functions for access to the Flickr API (see http://www.flickr.com/services/api for details).
Line # Kind Name Docs
51 Function sign_arguments Compute the 'api_sig' argument for methods that need signing (see
104 Function get_cached_token Return the authentication token that has been locally cached.
121 Function generate_call_uri Generate the URI to use for a Flickr API call using an HTTP GET method.
164 Function authenticate_1 First step of the authentication to the Flickr API: request a Frob (see
205 Function authenticate_2 Second step of the authentication to the Flickr API: return the auth token
230 Function build_photo_url Build the real URL corresponding to a photo model.
66 Function _get_token_file Return the filename that contains the authentication token for the API key.
75 Function _read_token Extract the authentication token from an XML response to
89 Function _save_token Save the retrieved authentication token to the local cache.
def sign_arguments(arguments):
Compute the 'api_sig' argument for methods that need signing (see http://www.flickr.com/services/api/auth.spec.html#signing for details).

This method updates the dictionary of arguments passed as a parameter, setting the value of the 'api_sig' argument.

Parametersargumentsthe arguments passed to the method that need signing (type: dict of {str} )
def _get_token_file():
Return the filename that contains the authentication token for the API key.
Returnsthe filename where to store the authentication token (type: str )
def _read_token(response):
Extract the authentication token from an XML response to flickr.auth.getToken.
Parametersresponsethe response to flickr.auth.getToken (type: str or unicode )
Returnsthe authentication token (type: str )
def _save_token(token):
Save the retrieved authentication token to the local cache.
Parameterstokenthe authentication token as returned by flickr.auth.getToken (type: str )
def get_cached_token():
Return the authentication token that has been locally cached.
Returnsthe authentication token (type: str )
RaisesIOErrorif the token cache file cannot be found
def generate_call_uri(base_uri=BASE_API_URI, method=None, arguments={}, authenticated=False, sign=False):
Generate the URI to use for a Flickr API call using an HTTP GET method.

The 'method' and 'api_key' arguments are automatically added if not present. If authentication is required, the 'auth_token' argument will be automatically added. If signing is required, the signature will be computed and the 'api_sig' argument added.

Parametersbase_urithe base URI of the request (type: str )
methodthe Flickr API method name (type: str )
argumentsthe arguments (key-value) of the method (type: dict of str )
authenticatedwhether the method requires authentication (type: bool )
signwhether the method requires signing (type: bool )
Returnsthe complete URI of the request to send (type: str )
def authenticate_1(provider):
First step of the authentication to the Flickr API: request a Frob (see http://www.flickr.com/services/api/flickr.auth.getFrob.html for details) and generate a login URL that the application should open in a browser window to let the user allow Elisa to access his content. Once the user has allowed the application to access his account, call the authenticate_2 method with the generated frob to get an authentication token.

If the application is already authenticated (authentication token locally cached), return the token. No subsequent call to authenticate_2 is needed.

Parametersproviderthe Flickr resource provider (type: elisa.plugins.flickr.resource_provider.FlickrResourceProvider )
Returnsa deferred that when fired returns a dictionary containing either the login URL and the frob, or the token if already authenticated. (type: twisted.internet.defer.Deferred )
def authenticate_2(provider, frob):
Second step of the authentication to the Flickr API: return the auth token for the given frob, if one has been attached.
Parametersproviderthe Flickr resource provider (type: elisa.plugins.flickr.resource_provider.FlickrResourceProvider )
frobthe frob (type: str )
Returnsthe authentication token if existing, None otherwise (type: str )
def build_photo_url(model):
Build the real URL corresponding to a photo model.

See http://www.flickr.com/services/api/misc.urls.html for details on how to build the URL of a photo. Once built this URL is cached in the model itself for faster subsequent accesses.

Parametersmodela photo model (type: elisa.plugins.flickr.models.FlickrPhotoModel )
API Documentation for Elisa Media Center, generated by pydoctor at 2009-02-16 19:15:05.