Commit abb36c89 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

no need to call hasConversion() before getConversion() because it does mostly...

no need to call hasConversion() before getConversion() because it does mostly the same thing and waste of time. use try ... except KeyError instead.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28375 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 372b7c16
...@@ -99,15 +99,19 @@ class PDFDocument(Image, ConversionCacheMixin): ...@@ -99,15 +99,19 @@ class PDFDocument(Image, ConversionCacheMixin):
Implementation of conversion for PDF files Implementation of conversion for PDF files
""" """
if format == 'html': if format == 'html':
if not self.hasConversion(format=format): try:
return self.getConversion(format=format)
except KeyError:
data = self._convertToHTML() data = self._convertToHTML()
self.setConversion(data, mime='text/html', format=format) self.setConversion(data, mime='text/html', format=format)
return self.getConversion(format=format) return (mime, aq_base(data))
elif format in ('txt', 'text'): elif format in ('txt', 'text'):
if not self.hasConversion(format='txt'): try:
return self.getConversion(format='txt')
except KeyError:
data = self._convertToText() data = self._convertToText()
self.setConversion(data, mime='text/plain', format='txt') self.setConversion(data, mime='text/plain', format='txt')
return self.getConversion(format='txt') return (mime, aq_base(data))
else: else:
return Image.convert(self, format, **kw) return Image.convert(self, format, **kw)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment