Thomas Waldmann  committed da0add7

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...

  • Participants
  • Parent commits 93dda0b
  • Branches gae

Comments (0)

Files changed (1)

File MoinMoin/items/

         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)
             # likely a non-existing item
             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:
         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: