# HG changeset patch # User Goffi # Date 1560362745 -7200 # Node ID aee3d8fa679fc4e9808f0e91a822e3c96f3c35e0 # Parent 7b05ebc46141021e7b65426d88bd4fe428a70bf6 pages: fixed cached data when `url_cache` is used: `request.template_data` and `request.data` where cached using a shallow copy, causing trouble when a mutable object was used. This has been fixed by using a deepcopy, which should not be a resource issue as `request.data` and `request.template_data` should contain a few data in most cases. diff -r 7b05ebc46141 -r aee3d8fa679f libervia/server/pages.py --- a/libervia/server/pages.py Wed Jun 12 09:12:09 2019 +0200 +++ b/libervia/server/pages.py Wed Jun 12 20:05:45 2019 +0200 @@ -39,6 +39,7 @@ import urllib import time import hashlib +import copy log = getLogger(__name__) @@ -82,18 +83,18 @@ def __init__(self, request): super(CacheURL, self).__init__() try: - self._data = request.data.copy() + self._data = copy.deepcopy(request.data) except AttributeError: self._data = {} - self._template_data = request.template_data.copy() + self._template_data = copy.deepcopy(request.template_data) self._prepath = request.prepath[:] self._postpath = request.postpath[:] del self._template_data["csrf_token"] def use(self, request): self.last_access = time.time() - request.data = self._data.copy() - request.template_data.update(self._template_data) + request.data = copy.deepcopy(self._data) + request.template_data.update(copy.deepcopy(self._template_data)) request.prepath = self._prepath[:] request.postpath = self._postpath[:]