]>
git.ipfire.org Git - ipfire.org.git/blob - www/webapp/handlers_iuse.py
5 from handlers_base
import *
8 class IUseImage(BaseHandler
):
15 return backend
.Stasy()
17 def get(self
, profile_id
, image_id
):
18 # Try to get the image from memcache. If we have a cache miss we
20 mem_id
= "iuse-%s-%s" % (profile_id
, image_id
)
21 image
= self
.memcached
.get(mem_id
)
24 image_cls
= self
.iuse
.get_imagetype(image_id
)
26 raise tornado
.web
.HTTPError(404, "Image class is unknown: %s" % image_id
)
28 profile
= self
.stasy
.get_profile(profile_id
)
30 raise tornado
.web
.HTTPError(404, "Profile '%s' was not found." % profile_id
)
33 image
= image_cls(profile
).to_string()
35 # Save the image to the memcache for 15 minutes
36 self
.memcached
.set(mem_id
, image
, 15*60)
38 self
.set_header("Content-type", "image/png")