changeset 188:a1a6a45edaf1

arnica: use StringIO file obj for cache.put(), remove unused code
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 17 Jul 2008 23:54:42 +0200
parents a0c61c78446e
children 5edba1f921b7
files data/plugin/parser/text_x_arnica.py
diffstat 1 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/parser/text_x_arnica.py	Thu Jul 17 23:30:23 2008 +0200
+++ b/data/plugin/parser/text_x_arnica.py	Thu Jul 17 23:54:42 2008 +0200
@@ -518,11 +518,8 @@
 
         cache_web = caching.CacheEntry(self.request, cache.cache_arena, webnail+'.data',
                                        cache.cache_scope, do_locking=False)
-        webnail_image_filename = cache_web._filename()
-
         cache_thumb = caching.CacheEntry(self.request, cache.cache_arena, thumbnail+'.data',
                                          cache.cache_scope, do_locking=False)
-        thumbnail_image_filename = cache_thumb._filename()
 
         if self.renew:
             cache_web.remove()
@@ -540,19 +537,21 @@
             if not cache_web.exists():
                 if not self.image_for_webnail:
                     im_obj.thumbnail((int(self.webnail_width.strip('px')), int(self.webnail_width.strip('px'))), Image.ANTIALIAS)
-                    buffer = StringIO.StringIO()
-                    im_obj.save(buffer, image_type)
-                    buffer.flush()
-                    cache.put(self.request, webnail, buffer.getvalue(), filename=image)
-                    buffer.close()
+                    buf = StringIO.StringIO()
+                    im_obj.save(buf, image_type)
+                    buf.flush()
+                    buf.seek(0)
+                    cache.put(self.request, webnail, buf, filename=image)
+                    buf.close()
 
             if not cache_thumb.exists():
                 im_obj.thumbnail((int(self.thumbnail_width.strip('px')), int(self.thumbnail_width.strip('px'))), Image.ANTIALIAS)
-                buffer = StringIO.StringIO()
-                im_obj.save(buffer, image_type)
-                buffer.flush()
-                cache.put(self.request, thumbnail, buffer.getvalue(), filename=image)
-                buffer.close()
+                buf = StringIO.StringIO()
+                im_obj.save(buf, image_type)
+                buf.flush()
+                buf.seek(0)
+                cache.put(self.request, thumbnail, buf, filename=image)
+                buf.close()
 
     def render(self, formatter):
         """ renders thumbnails """