From 49cc4400de726b0cd714dbd70a4a53fedf7ddb4a Mon Sep 17 00:00:00 2001 From: Tatuya Kamada <tatuya@nexedi.com> Date: Thu, 9 Apr 2009 05:40:28 +0000 Subject: [PATCH] * 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 --- product/ERP5OOo/FormPrintout.py | 14 +++++++------- product/ERP5OOo/tests/testFormPrintout.py | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/product/ERP5OOo/FormPrintout.py b/product/ERP5OOo/FormPrintout.py index 61c0d51b4d..990ad5a00e 100644 --- a/product/ERP5OOo/FormPrintout.py +++ b/product/ERP5OOo/FormPrintout.py @@ -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=''): diff --git a/product/ERP5OOo/tests/testFormPrintout.py b/product/ERP5OOo/tests/testFormPrintout.py index 4042dbf378..ab5155bae5 100644 --- a/product/ERP5OOo/tests/testFormPrintout.py +++ b/product/ERP5OOo/tests/testFormPrintout.py @@ -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") -- 2.30.9