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

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Aug 17 10:53:13 CEST 2009


Author: kazuhiko
Date: Mon Aug 17 10:53:12 2009
New Revision: 28405

URL: http://svn.erp5.org?rev=28405&view=rev
Log:
set a content-disposition header with an appropriate filename and cache headers in PDFDocument.index_html() if no format is specified.

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=28405&r1=28404&r2=28405&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/PDFDocument.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/PDFDocument.py [utf8] Mon Aug 17 10:53:12 2009
@@ -28,7 +28,8 @@
 import tempfile, os, cStringIO
 
 from AccessControl import ClassSecurityInfo
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByName, _setCacheHeaders,\
+    _ViewEmulator
 
 from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces
 from Products.ERP5Type.Cache import CachingMethod
@@ -79,7 +80,14 @@
       it is always a zip because multi-page pdfs are converted into a zip
       file of many images
     """
-    if format is None:
+    _setCacheHeaders(_ViewEmulator().__of__(self), {'format' : format})
+    if format is '':
+      if self.getSourceReference() is not None:
+        filename = self.getSourceReference()
+      else:
+        filename = self.getId()
+      RESPONSE.setHeader('Content-Disposition',
+                         'attachment; filename="%s"' % filename)
       RESPONSE.setHeader('Content-Type', 'application/pdf')
       return str(self.data)
     if format in ('html', 'txt', 'text'):




More information about the Erp5-report mailing list