comparison data/plugin/parser/text_x_arnica.py @ 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 a2a5dedfeb1d
children 192f39a549e9
comparison
equal deleted inserted replaced
187:a0c61c78446e 188:a1a6a45edaf1
516 516
517 page = Page(self.request, self.pagename) 517 page = Page(self.request, self.pagename)
518 518
519 cache_web = caching.CacheEntry(self.request, cache.cache_arena, webnail+'.data', 519 cache_web = caching.CacheEntry(self.request, cache.cache_arena, webnail+'.data',
520 cache.cache_scope, do_locking=False) 520 cache.cache_scope, do_locking=False)
521 webnail_image_filename = cache_web._filename()
522
523 cache_thumb = caching.CacheEntry(self.request, cache.cache_arena, thumbnail+'.data', 521 cache_thumb = caching.CacheEntry(self.request, cache.cache_arena, thumbnail+'.data',
524 cache.cache_scope, do_locking=False) 522 cache.cache_scope, do_locking=False)
525 thumbnail_image_filename = cache_thumb._filename()
526 523
527 if self.renew: 524 if self.renew:
528 cache_web.remove() 525 cache_web.remove()
529 cache_thumb.remove() 526 cache_thumb.remove()
530 527
538 535
539 # XXX later, a unit conversion method for using other units than 'px' is needed 536 # XXX later, a unit conversion method for using other units than 'px' is needed
540 if not cache_web.exists(): 537 if not cache_web.exists():
541 if not self.image_for_webnail: 538 if not self.image_for_webnail:
542 im_obj.thumbnail((int(self.webnail_width.strip('px')), int(self.webnail_width.strip('px'))), Image.ANTIALIAS) 539 im_obj.thumbnail((int(self.webnail_width.strip('px')), int(self.webnail_width.strip('px'))), Image.ANTIALIAS)
543 buffer = StringIO.StringIO() 540 buf = StringIO.StringIO()
544 im_obj.save(buffer, image_type) 541 im_obj.save(buf, image_type)
545 buffer.flush() 542 buf.flush()
546 cache.put(self.request, webnail, buffer.getvalue(), filename=image) 543 buf.seek(0)
547 buffer.close() 544 cache.put(self.request, webnail, buf, filename=image)
545 buf.close()
548 546
549 if not cache_thumb.exists(): 547 if not cache_thumb.exists():
550 im_obj.thumbnail((int(self.thumbnail_width.strip('px')), int(self.thumbnail_width.strip('px'))), Image.ANTIALIAS) 548 im_obj.thumbnail((int(self.thumbnail_width.strip('px')), int(self.thumbnail_width.strip('px'))), Image.ANTIALIAS)
551 buffer = StringIO.StringIO() 549 buf = StringIO.StringIO()
552 im_obj.save(buffer, image_type) 550 im_obj.save(buf, image_type)
553 buffer.flush() 551 buf.flush()
554 cache.put(self.request, thumbnail, buffer.getvalue(), filename=image) 552 buf.seek(0)
555 buffer.close() 553 cache.put(self.request, thumbnail, buf, filename=image)
554 buf.close()
556 555
557 def render(self, formatter): 556 def render(self, formatter):
558 """ renders thumbnails """ 557 """ renders thumbnails """
559 558
560 _ = self._ 559 _ = self._