]>
git.ipfire.org Git - ipfire.org.git/blob - www/webapp/handlers_iuse.py
e0b003a69668ffaa523ad9d0804796838fbaf457
6 from handlers_base
import *
9 class IUseImage(BaseHandler
):
16 return backend
.Stasy()
18 def get(self
, profile_id
, image_id
):
20 # Try to get the image from memcache. If we have a cache miss we
22 mem_id
= "iuse-%s-%s-%s" % (profile_id
, image_id
, self
.locale
.code
)
24 cache
= self
.get_argument("cache", "true")
26 image
= self
.memcached
.get(mem_id
)
29 logging
.debug("Got image from cache for profile: %s" % profile_id
)
31 logging
.info("Rendering new image for profile: %s" % profile_id
)
33 image_cls
= self
.iuse
.get_imagetype(image_id
)
35 raise tornado
.web
.HTTPError(404, "Image class is unknown: %s" % image_id
)
37 profile
= self
.stasy
.get_profile(profile_id
)
39 raise tornado
.web
.HTTPError(404, "Profile '%s' was not found." % profile_id
)
42 image
= image_cls(self
, profile
).to_string()
44 # Save the image to the memcache for 15 minutes
45 self
.memcached
.set(mem_id
, image
, 15*60)
47 self
.set_header("Content-Type", "image/png")