Commit 49cc4400 authored by Tatuya Kamada's avatar Tatuya Kamada

* Fix

 - set 'View' permission to index_html method as well as r26362
 - when just call FormPrintout from Python script or python code,
   must not set RESPONSE headers



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26363 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 030d01a4
......@@ -150,7 +150,7 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item):
self.form_name = form_name
self.template = template
security.declareProtected('View management screens', 'index_html')
security.declareProtected('View', 'index_html')
def index_html(self, icon=0, preview=0, width=None, height=None, REQUEST=None):
"""Render and view a printout document."""
......@@ -178,14 +178,14 @@ class FormPrintout(Implicit, Persistent, RoleManager, Item):
content_type = printout_template.content_type
self.strategy = self._createStrategy(content_type)
printout = self.strategy.render(extra_context=extra_context)
REQUEST.RESPONSE.setHeader('Content-Type','%s; charset=utf-8' % content_type)
REQUEST.RESPONSE.setHeader('Content-disposition',
'inline;filename="%s%s"' % (self.title_or_id(), guess_extension(content_type)))
if REQUEST is not None:
REQUEST.RESPONSE.setHeader('Content-Type','%s; charset=utf-8' % content_type)
REQUEST.RESPONSE.setHeader('Content-disposition',
'inline;filename="%s%s"' % (self.title_or_id(), guess_extension(content_type)))
return printout
security.declareProtected('View', '__call__')
def __call__(self, *args, **kwargs):
return self.index_html(REQUEST=get_request())
security.declareProtected('View', '__call__')
__call__ = index_html
security.declareProtected('Manage properties', 'doSettings')
def doSettings(self, REQUEST, title='', form_name='', template=''):
......
......@@ -162,6 +162,8 @@ class TestFormPrintout(ERP5TypeTestCase):
builder = OOoBuilder(odf_document)
content_xml = builder.extract("content.xml")
self.assertTrue(content_xml.find("call!") > 0)
# when just call FormPrintout, it does not set content-type
self.assertEqual(request.RESPONSE.getHeader('Content-Type'), None)
# 5. Normal case: utf-8 string
test1.setTitle("Français")
......
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