changeset 2051:da0add742730 gae

fix cache key computation bug we used the hash of the data as cache key at some places. but as we also have metadata and metadata might be different for same data hash, this leads to problems. solved now by just using the revid (which is a UUID). this fixes some tests that were broken here since enabling usage of app.cache, as often data was just '' (-> always same hash), but contenttype was sometimes a wiki page, sometimes an image, so e.g. the internal representation was expected to be different. As it used a wrong cached internal representation, tests were failing...
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 24 Mar 2013 18:58:41 +0100
parents 93dda0b6b319
children 8143d27c68a9
files MoinMoin/items/content.py
diffstat 1 files changed, 6 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/content.py	Sun Mar 24 18:57:43 2013 +0100
+++ b/MoinMoin/items/content.py	Sun Mar 24 18:58:41 2013 +0100
@@ -182,12 +182,9 @@
         """
         Return the internal representation of a document using a DOM Tree
         """
-        hash_name = HASH_ALGORITHM
-        hash_hexdigest = self.rev.meta.get(hash_name)
-        if hash_hexdigest:
-            cid = cache_key(usage="internal_representation",
-                            hash_name=hash_name,
-                            hash_hexdigest=hash_hexdigest)
+        revid = self.rev.revid
+        if revid:
+            cid = cache_key(usage="internal_representation", revid=revid)
             doc = app.cache.get(cid)
         else:
             # likely a non-existing item
@@ -695,11 +692,8 @@
             transpose = 1
         if width or height or transpose != 1:
             # resize requested, XXX check ACL behaviour! XXX
-            hash_name = HASH_ALGORITHM
-            hash_hexdigest = self.rev.meta[hash_name]
             cid = cache_key(usage="ImageTransform",
-                            hash_name=hash_name,
-                            hash_hexdigest=hash_hexdigest,
+                            revid=self.rev.revid,
                             width=width, height=height, transpose=transpose)
             c = app.cache.get(cid)
             if c is None:
@@ -735,11 +729,9 @@
         return Markup(u'<img src="{0}" />'.format(escape(url)))
 
     def _render_data_diff_raw(self, oldrev, newrev):
-        hash_name = HASH_ALGORITHM
         cid = cache_key(usage="ImageDiff",
-                        hash_name=hash_name,
-                        hash_old=oldrev.meta[hash_name],
-                        hash_new=newrev.meta[hash_name])
+                        revid_old=oldrev.revid,
+                        revid_new=newrev.revid)
         c = app.cache.get(cid)
         if c is None:
             if PIL is None: