Commit 001227c1 authored by Yusei Tahara's avatar Yusei Tahara

Cache the result value of getContentInformation method.

This method could consume much cpu if too many pages in a document.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18698 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 06828d4e
...@@ -165,6 +165,10 @@ class PDFDocument(Image, ConversionCacheMixin): ...@@ -165,6 +165,10 @@ class PDFDocument(Image, ConversionCacheMixin):
NOTE: XXX check that command exists and was executed NOTE: XXX check that command exists and was executed
successfully successfully
""" """
try:
return self._content_information.copy()
except AttributeError:
pass
tmp = tempfile.NamedTemporaryFile() tmp = tempfile.NamedTemporaryFile()
tmp.write(_unpackData(self.data)) tmp.write(_unpackData(self.data))
tmp.seek(0) tmp.seek(0)
...@@ -179,4 +183,12 @@ class PDFDocument(Image, ConversionCacheMixin): ...@@ -179,4 +183,12 @@ class PDFDocument(Image, ConversionCacheMixin):
key = item_list[0].strip() key = item_list[0].strip()
value = ':'.join(item_list[1:]).strip() value = ':'.join(item_list[1:]).strip()
result[key] = value result[key] = value
return result self._content_information = result
return result.copy()
def _setFile(self, data, precondition=None):
try:
del self._content_information
except AttributeError:
pass
Image._setFile(self, data, precondition)
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