Esempio n. 1
0
def img_tag(environment, value, prefix=''):
    if value is None:
        return ''
    i = memcache.get(value)
    if i is None:
        i = Image.get(value)
        if i:
            memcache.add(value, i, 7200)
    if i:
        return Markup(i.img_tag(prefix))
    return ''
Esempio n. 2
0
def img_url(environment, value):
    if value is None:
        return ''
    i = memcache.get(value)
    if i is None:
        i = Image.get(value)
        if i:
            memcache.add(value, i, 7200)
    if i:
        return Markup(i.url())
    return ''
Esempio n. 3
0
File: views.py Progetto: gmist/f-toy
def get_img(request, key, ext):
    im = memcache.get(key)
    if not im:
        im = Image.get(key)
        if im:
            memcache.add(key, im, 7200)
    if im:
        headers = Headers()
        headers['Content-Type'] = im.content_type
        headers['Last-Modified'] = im.modif_time.strftime(HTTP_DATE_FMT)
        current_day = datetime.today()
        exp_delta = timedelta(days=7)
        headers['Expires'] = (current_day + exp_delta).strftime(HTTP_DATE_FMT)

        response = Response(im.image, headers=headers)
    else:
        response = Response(status=304)
    return response