Beispiel #1
0
 def notfound():
     if config.default_image and i.default.lower() != "false" and not i.default.startswith('http://'):
         return read_file(config.default_image)
     elif i.default.startswith('http://'):
         raise web.seeother(i.default)
     else:
         raise web.notfound("")
Beispiel #2
0
 def notfound():
     if config.default_image and i.default.lower() != "false" and not i.default.startswith('http://'):
         return read_file(config.default_image)
     elif i.default.startswith('http://'):
         raise web.seeother(i.default)
     else:
         raise web.notfound("")
Beispiel #3
0
 def notfound():
     if key in ["id", "olid"] and config.get("upstream_base_url"):
         # this is only used in development
         base = web.rstrips(config.upstream_base_url, "/")
         raise web.redirect(base + web.ctx.fullpath)
     elif config.default_image and i.default.lower() != "false" and not is_valid_url(i.default):
         return read_file(config.default_image)
     elif is_valid_url(i.default):
         raise web.seeother(i.default)
     else:
         raise web.notfound("")
Beispiel #4
0
 def GET(self, category, key, value, size):
     i = web.input(default="true")
     key = key.lower()
     
     d = _query(category, key, value)
     if d:
         if key == 'id':
             etag = "%s-%s" % (d.id, size.lower())
             if not web.modified(trim_microsecond(d.created), etag=etag):
                 raise web.notmodified()
             web.header('Cache-Control', 'public')
             web.expires(100 * 365 * 24 * 3600) # this image is not going to expire in next 100 years.
             
         web.header('Content-Type', 'image/jpeg')
         return read_image(d, size)
     elif config.default_image and i.default.lower() != "false" and not i.default.startswith('http://'):
         return read_file(config.default_image)
     elif i.default.startswith('http://'):
         raise web.seeother(i.default)
     else:
         raise web.notfound("")