Issues

Issue #1 new

Support for federated avatars using pyLibravatar

Francois Marier
created an issue

Here's a suggestion to extend your Libravatar backend and easily add support for avatars hosted on domains other than libravatar.org.

You can make use of the pyLibravatar module: https://pypi.python.org/pypi/pyLibravatar

All you need to do to generate avatar URLs is this:

avatar_url = libravatar_url(email = 'user@example.com', https = 1)

Comments (6)

  1. Mike Bayer repo owner

    correct me if I'm wrong but looking at the source at http://bazaar.launchpad.net/~libravatar/pylibravatar/trunk/view/head:/libravatar.py it appears that each call to libravatar_url(), for which a naive implementation on our end would be called hundreds of times server side for some listings, performs a brand new DNS lookup ? this seems wasteful when some simple caching would eliminate lots of python/system/network calls.

    also is "_avatars._tcp.<domain>" some kind of standard or is this specific to pylibravatar ?

  2. Mike Bayer repo owner

    libravatar could allow for stateful usage pretty easily by basing it's API around a contextual object, like:

    ctx = pylibravatar.Context(cache=True)
    avatar_url = ctx.url("user@example.com", https=True)
    

    where above ctx.url() would load the avatar from a local dictionary if already present - or better yet an LRU cache with a configurable size and an expiration time).

    the "ctx" here could at least hang around for the lifespan of a whole request, or be held persistently across requests.

  3. Francois Marier reporter

    That context object is a good idea.

    The thing about DNS though is that it's the world's largest caching system. I'm not sure I can do a better job than it does given that caching is built into all DNS resolution. After all, cache invalidation is one of the hardest problems in computer science :)

    You might be right that it would be worth adding another layer of caching on top, but I would be inclined to see if it's actually a problem before implementing something like this.

  4. Mike Bayer repo owner

    do 100 libravatar lookups and run it under cProfile, then compare to pulling the values out of a Python dictionary. My guess is you'll see a callcount difference well over two orders of magnitude.

  5. Log in to comment