]>
git.ipfire.org Git - ipfire.org.git/blob - src/web/handlers_accounts.py
6 from .handlers_base
import *
8 class AccountsAvatarHandler(BaseHandler
):
10 # Get the desired size of the avatar file
11 size
= self
.get_argument("size", 0)
15 except (TypeError, ValueError):
19 cache_handle
= "accounts-avatar-%s-%s" % (who
, size
or 0)
20 avatar
= self
.memcached
.get(cache_handle
)
23 logging
.debug("Querying for avatar of %s" % who
)
25 account
= self
.backend
.accounts
.get_by_uid(who
)
27 raise tornado
.web
.HTTPError(404)
29 avatar
= account
.get_avatar(size
)
31 # Save the avatar to cache for 6 hours
33 self
.memcached
.set(cache_handle
, avatar
, 6 * 3600)
35 # Otherwise raise 404 (XXX should send a default image)
37 raise tornado
.web
.HTTPError(404, "No avatar set for %s" % account
)
39 self
.set_header("Cache-Control", "public,max-age=300")
40 self
.set_header("Content-Disposition", "inline; filename=\"%s.jpg\"" % who
)
41 self
.set_header("Content-Type", "image/jpeg")