[Erp5-report] r18698 - /erp5/trunk/products/ERP5/Document/PDFDocument.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jan 14 18:03:05 CET 2008


Author: yusei
Date: Mon Jan 14 18:03:03 2008
New Revision: 18698

URL: http://svn.erp5.org?rev=18698&view=rev
Log:
Cache the result value of getContentInformation method.
This method could consume much cpu if too many pages in a document.

Modified:
    erp5/trunk/products/ERP5/Document/PDFDocument.py

Modified: erp5/trunk/products/ERP5/Document/PDFDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PDFDocument.py?rev=18698&r1=18697&r2=18698&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/PDFDocument.py (original)
+++ erp5/trunk/products/ERP5/Document/PDFDocument.py Mon Jan 14 18:03:03 2008
@@ -165,6 +165,10 @@
     NOTE: XXX check that command exists and was executed
     successfully
     """
+    try:
+      return self._content_information.copy()
+    except AttributeError:
+      pass
     tmp = tempfile.NamedTemporaryFile()
     tmp.write(_unpackData(self.data))
     tmp.seek(0)
@@ -179,4 +183,12 @@
       key = item_list[0].strip()
       value = ':'.join(item_list[1:]).strip()
       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)




More information about the Erp5-report mailing list