Mercurial > moin > 1.9
changeset 3892:85c7b3b9c48c
cache action: use dict for metadata, store also original item name and last_modified (as UNIX timestamp)
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Sun, 20 Jul 2008 17:00:07 +0200 |
parents | a96636a03024 |
children | 3be52acb3f43 |
files | MoinMoin/action/cache.py |
diffstat | 1 files changed, 15 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/action/cache.py Sun Jul 20 14:31:36 2008 +0200 +++ b/MoinMoin/action/cache.py Sun Jul 20 17:00:07 2008 +0200 @@ -107,7 +107,8 @@ content_type=None, content_disposition=None, content_length=None, - last_modified=None): + last_modified=None, + original=None): """ Put an object into the cache to send it with cache action later. @@ -120,6 +121,9 @@ @param content_disposition: type for content-disposition header (str, default: None) @param content_length: data length for content-length header (int, default: autodetect) @param last_modified: last modified timestamp (int, default: autodetect) + @param original: location of original object (default: None) - this is just written to + the metadata cache "as is" and could be used for cache cleanup, + use (wikiname, itemname, attachname or None)) """ import os.path from MoinMoin.util import timefuncs @@ -142,9 +146,9 @@ content_length = content_length or data_cache.size() last_modified = last_modified or data_cache.mtime() - last_modified = timefuncs.formathttpdate(int(last_modified)) + httpdate_last_modified = timefuncs.formathttpdate(int(last_modified)) headers = ['Content-Type: %s' % content_type, - 'Last-Modified: %s' % last_modified, + 'Last-Modified: %s' % httpdate_last_modified, 'Content-Length: %s' % content_length, ] if content_disposition and filename: @@ -154,7 +158,12 @@ headers.append('Content-Disposition: %s; filename="%s"' % (content_disposition, filename)) meta_cache = caching.CacheEntry(request, cache_arena, key+'.meta', cache_scope, do_locking=do_locking, use_pickle=True) - meta_cache.update((last_modified, headers)) + meta_cache.update({ + 'httpdate_last_modified': httpdate_last_modified, + 'last_modified': last_modified, + 'headers': headers, + 'original':original, + }) def exists(request, key, strict=False): @@ -196,8 +205,8 @@ def _get_headers(request, key): """ get last_modified and headers cached for key """ meta_cache = caching.CacheEntry(request, cache_arena, key+'.meta', cache_scope, do_locking=do_locking, use_pickle=True) - last_modified, headers = meta_cache.content() - return last_modified, headers + meta = meta_cache.content() + return meta['httpdate_last_modified'], meta['headers'] def _get_datafile(request, key):