Store cache files in a better way

Add 'pickled' suffix instead of file extensions to not to mislead
users. Files stored in cache as pickled objects, so
they can be open as regular files.

Change-Id: Ia6418696cf81de2bb1add175f27b6465fc91f6b9
Closes-Bug: #1520515
This commit is contained in:
Ekaterina Chernova 2016-01-20 18:39:35 +03:00
parent e3d0764c4c
commit 7216f73185

View File

@ -66,6 +66,9 @@ def with_cache(*dst_parts):
@functools.wraps(func)
def __inner(request, app_id):
path = os.path.join(_get_entry_path(app_id), *dst_parts)
# Remove file extensions since file content is pickled and
# could not be open as usual files
path = os.path.splitext(path)[0] + '-pickled'
content = _load_from_file(path)
if content is None:
content = func(request, app_id)