If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

First you need to generate an APIKEY for you, you can do that on Flickr Developers page

After that you need to create a function to fetch the flickr API, generaly this is created in models, but you can do that in modules too.

Create a function in any of your model files


def get_flickerset(pset=None, per_page=15, page=1):
    from urllib2 import urlopen
    from xml.dom.minidom import parse as domparse
    apiurl = 'http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=%(apikey)s&photoset_id=%(pset)s&privacy_filter=1&per_page=%(per_page)s&page=%(page)s&extras=url_t,url_m,url_o,url_sq'
    dom = domparse(urlopen(apiurl % dict(pset=pset, per_page=per_page, page=page, apikey=APIKEY)))

    photos = []

    for node in dom.getElementsByTagName('photo'):

    return photos

Now you can call that funtion from controller or views:

def testflickr():

    photos=get_flickerset(pset='THE_PHOTOSET_ID', per_page=15, page=1)

    return locals()

In view do that

{{for photo in photos:}}

The final

alt text

Related slices

Comments (0)

Hosting graciously provided by:
Python Anywhere