From ce40ae2ae1fc3d50b0dec6be5eedbcebdd14130f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Mon, 23 Jun 2008 09:32:41 +0000 Subject: [PATCH] File.index_html must be called after setting headers, otherwise the filename is sometimes "Base_download" Problem: if an error happens during index_html, content disposition will be set, so the browser will ask to save a file containing html error text git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21736 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../portal_skins/erp5_core/Base_download.xml | 22 ++++++++++++------- product/ERP5/bootstrap/erp5_core/bt/revision | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_download.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_download.xml index 79be519dc5..67822427f3 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_download.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_download.xml @@ -70,12 +70,6 @@ response = request.RESPONSE\n \n from zExceptions import Unauthorized\n \n -try:\n - result = context.index_html(request, response)\n -except Unauthorized:\n - msg = context.Base_translateString("You don\'t have enough permission for converting this document.")\n - return context.Base_redirect(keep_items=dict(portal_status_message=msg))\n -\n if hasattr(context,\'getContentType\'):\n response.setHeader(\'Content-type\', context.getContentType())\n else:\n @@ -84,6 +78,12 @@ else:\n file_name = context.getSourceReference() or context.getTitle() or context.getId()\n response.setHeader(\'Content-disposition\', \'attachment; filename="%s"\' % file_name)\n \n +try:\n + result = context.index_html(request, response)\n +except Unauthorized:\n + msg = context.Base_translateString("You don\'t have enough permission for converting this document.")\n + return context.Base_redirect(keep_items=dict(portal_status_message=msg))\n +\n return result\n </string> </value> </item> @@ -99,6 +99,12 @@ return result\n <none/> </value> </item> + <item> + <key> <string>_owner</string> </key> + <value> + <none/> + </value> + </item> <item> <key> <string>_params</string> </key> <value> <string></string> </value> @@ -133,12 +139,12 @@ return result\n <string>response</string> <string>zExceptions</string> <string>Unauthorized</string> + <string>hasattr</string> <string>context</string> + <string>file_name</string> <string>result</string> <string>msg</string> <string>dict</string> - <string>hasattr</string> - <string>file_name</string> </tuple> </value> </item> diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision index 90064a9062..e2a83a8ce3 100644 --- a/product/ERP5/bootstrap/erp5_core/bt/revision +++ b/product/ERP5/bootstrap/erp5_core/bt/revision @@ -1 +1 @@ -854 \ No newline at end of file +855 \ No newline at end of file -- 2.30.9