changeset 1639:95efbd8cfa55

caching: use pickle for pagelinks, too
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 22 Oct 2006 22:21:44 +0200
parents 5070d0358544
children 6478c7744221
files MoinMoin/Page.py
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/Page.py	Sun Oct 22 20:48:23 2006 +0200
+++ b/MoinMoin/Page.py	Sun Oct 22 22:21:44 2006 +0200
@@ -1166,10 +1166,10 @@
 
         # cache the pagelinks
         if do_cache and self.default_formatter and page_exists:
-            cache = caching.CacheEntry(request, self, 'pagelinks', scope='item')
+            cache = caching.CacheEntry(request, self, 'pagelinks', scope='item', use_pickle=True)
             if cache.needsUpdate(self._text_filename()):
                 links = self.formatter.pagelinks
-                cache.update('\n'.join(links) + '\n', True)
+                cache.update(links)
 
         request.clock.stop('send_page')
         if not content_only and self.default_formatter:
@@ -1421,13 +1421,18 @@
         """
         if not self.exists():
             return []
-        cache = caching.CacheEntry(request, self, 'pagelinks', scope='item', do_locking=False)
+        cache = caching.CacheEntry(request, self, 'pagelinks', scope='item', do_locking=False, use_pickle=True)
         if cache.needsUpdate(self._text_filename()):
             links = self.parsePageLinks(request)
-            cache.update('\n'.join(links) + '\n', True)
+            cache.update(links)
             return links
-        links = cache.content(True).split('\n')
-        return [link for link in links if link]
+        try:
+            links = cache.content()
+            return links
+        except caching.CacheError:
+            links = self.parsePageLinks(request)
+            cache.update(links)
+            return links
 
     def parsePageLinks(self, request):
         """ Parse page links by formatting with a pagelinks formatter