changeset 180:17e1c3d004bf

text_x_arnica: cache data from PIL based on StringIO
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 17 Jul 2008 20:25:49 +0200
parents 00e363a155c4
children b19e4e36a1f2
files data/plugin/parser/text_x_arnica.py
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/parser/text_x_arnica.py	Wed Jul 16 20:29:51 2008 +0200
+++ b/data/plugin/parser/text_x_arnica.py	Thu Jul 17 20:25:49 2008 +0200
@@ -529,19 +529,19 @@
             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)
-                    # ToDo find a way to add the im_obj data immediately to the cache arena
-                    im_obj.save(webnail_image_filename, image_type)
-                    st = os.stat(webnail_image_filename)
-                    cache.put(self.request, webnail, 'dummy', filename=image, content_length=st.st_size)
-                    im_obj.save(webnail_image_filename, image_type)
+                    buffer = StringIO.StringIO()
+                    im_obj.save(buffer, image_type)
+                    buffer.flush()
+                    cache.put(self.request, webnail, buffer.getvalue(), filename=image)
+                    buffer.close()
 
             if not cache_thumb.exists():
                 im_obj.thumbnail((int(self.thumbnail_width.strip('px')), int(self.thumbnail_width.strip('px'))), Image.ANTIALIAS)
-                # ToDo find a way to add the im_obj data immediately to the cache arena
-                im_obj.save(thumbnail_image_filename, image_type)
-                st = os.stat(thumbnail_image_filename)
-                cache.put(self.request, thumbnail, 'dummy', filename=image, content_length=st.st_size)
-                im_obj.save(thumbnail_image_filename, image_type)
+                buffer = StringIO.StringIO()
+                im_obj.save(buffer, image_type)
+                buffer.flush()
+                cache.put(self.request, thumbnail, buffer.getvalue(), filename=image)
+                buffer.close()
 
     def render(self, formatter):
         """ renders thumbnails """