Commit 1bd31125 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

set a content-disposition header with an appropriate filename and cache...

set a content-disposition header with an appropriate filename and cache headers in PDFDocument.index_html() if no format is specified.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28405 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 52a83cd1
......@@ -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 @@ class PDFDocument(Image, ConversionCacheMixin):
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'):
......
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