changeset 199:b82d3ce1764a

action cache method used instead of similiar one from caching
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 20 Jul 2008 18:41:15 +0200
parents d13bd1096377
children 833c10d63d94
files data/plugin/action/arnica_slides.py data/plugin/parser/text_x_arnica.py
diffstat 2 files changed, 13 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/arnica_slides.py	Sun Jul 20 17:42:57 2008 +0200
+++ b/data/plugin/action/arnica_slides.py	Sun Jul 20 18:41:15 2008 +0200
@@ -14,7 +14,7 @@
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from MoinMoin import caching, config, wikiutil
+from MoinMoin import config, wikiutil
 from MoinMoin.Page import Page
 from MoinMoin.action import ActionBase, AttachFile, cache
 from MoinMoin.formatter.text_html import Formatter
@@ -411,10 +411,6 @@
         # View Slides
         if command == 'slide_show':
             self.slide_show(pagename)
-        # view sends a cached attachment (thumbnail or webnail) to the browser
-        elif command == 'view':
-            arena_dir = caching.get_arena_dir(request, page, 'item')
-            send_cache_file(request, pagename, arena_dir, target) # XXX function missing!
 
         # only users which are allowed to delete should use this tool
         elif request.user.may.delete(pagename):
@@ -437,10 +433,8 @@
                 webnail = "tmp.webnail_%(file)s.jpg"  % {"file": filename}
 
             if command in ('delete', 'rotate_left', 'rotate_right', ):
-                cache_web = caching.CacheEntry(request, page, webnail, scope='item', use_pickle=True)
-                cache_web.remove()
-                cache_thumb = caching.CacheEntry(request, page, thumbfile, scope='item', use_pickle=True)
-                cache_thumb.remove()
+                cache.remove(self.request, webnail)
+                cache.remove(self.request, thumbfile)
 
             infile = AttachFile.getFilename(request, pagename, target)
 
--- a/data/plugin/parser/text_x_arnica.py	Sun Jul 20 17:42:57 2008 +0200
+++ b/data/plugin/parser/text_x_arnica.py	Sun Jul 20 18:41:15 2008 +0200
@@ -32,7 +32,7 @@
 try:
     import ExifTags
 except ImportError:
-    ExifTags = None    
+    ExifTags = None
 
 parser_name = __name__.split('.')[-1]
 
@@ -231,9 +231,10 @@
         if wikiutil.isPicture(file_name):
             date_key = 'D%s' % key
 
-            cache_date = caching.CacheEntry(self.request, cache.cache_arena, date_key+'.data',
+            
+            if cache.exists(self.request, date_key):
+                cache_date = caching.CacheEntry(self.request, cache.cache_arena, date_key+'.data',
                                        cache.cache_scope, do_locking=False)
-            if cache_date.exists():
                 return cache_date.content()
 
             try:
@@ -539,16 +540,11 @@
 
         page = Page(self.request, self.pagename)
 
-        cache_web = caching.CacheEntry(self.request, cache.cache_arena, webnail+'.data',
-                                       cache.cache_scope, do_locking=False)
-        cache_thumb = caching.CacheEntry(self.request, cache.cache_arena, thumbnail+'.data',
-                                         cache.cache_scope, do_locking=False)
+        if self.renew:
+            cache.remove(self.request, webnail)
+            cache.remove(self.request, thumbnail)
 
-        if self.renew:
-            cache_web.remove()
-            cache_thumb.remove()
-
-        if not cache_web.exists() or not cache_thumb.exists():
+        if not cache.exists(self.request, webnail) or not cache.exists(self.request, thumbnail):
             try:
                 im_obj = Image.open(imagef)
             except IOError:
@@ -557,7 +553,7 @@
                 return
 
            # XXX later, a unit conversion method for using other units than 'px' is needed
-            if not cache_web.exists():
+            if not cache.exists(self.request, webnail):
                 if not self.image_for_webnail:
                     im_obj.thumbnail((int(self.webnail_width.strip('px')), int(self.webnail_width.strip('px'))), Image.ANTIALIAS)
                     buf = StringIO.StringIO()
@@ -567,7 +563,7 @@
                     cache.put(self.request, webnail, buf, filename=image)
                     buf.close()
 
-            if not cache_thumb.exists():
+            if not cache.exists(self.request, thumbnail):
                 im_obj.thumbnail((int(self.thumbnail_width.strip('px')), int(self.thumbnail_width.strip('px'))), Image.ANTIALIAS)
                 buf = StringIO.StringIO()
                 im_obj.save(buf, image_type)