Commit ce40ae2a authored by Jérome Perrin's avatar Jérome Perrin

File.index_html must be called after setting headers, otherwise the filename...

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
parent 511cc567
...@@ -70,12 +70,6 @@ response = request.RESPONSE\n ...@@ -70,12 +70,6 @@ response = request.RESPONSE\n
\n \n
from zExceptions import Unauthorized\n from zExceptions import Unauthorized\n
\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 if hasattr(context,\'getContentType\'):\n
response.setHeader(\'Content-type\', context.getContentType())\n response.setHeader(\'Content-type\', context.getContentType())\n
else:\n else:\n
...@@ -84,6 +78,12 @@ else:\n ...@@ -84,6 +78,12 @@ else:\n
file_name = context.getSourceReference() or context.getTitle() or context.getId()\n file_name = context.getSourceReference() or context.getTitle() or context.getId()\n
response.setHeader(\'Content-disposition\', \'attachment; filename="%s"\' % file_name)\n response.setHeader(\'Content-disposition\', \'attachment; filename="%s"\' % file_name)\n
\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 return result\n
</string> </value> </string> </value>
</item> </item>
...@@ -99,6 +99,12 @@ return result\n ...@@ -99,6 +99,12 @@ return result\n
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -133,12 +139,12 @@ return result\n ...@@ -133,12 +139,12 @@ return result\n
<string>response</string> <string>response</string>
<string>zExceptions</string> <string>zExceptions</string>
<string>Unauthorized</string> <string>Unauthorized</string>
<string>hasattr</string>
<string>context</string> <string>context</string>
<string>file_name</string>
<string>result</string> <string>result</string>
<string>msg</string> <string>msg</string>
<string>dict</string> <string>dict</string>
<string>hasattr</string>
<string>file_name</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
854 855
\ No newline at end of file \ No newline at end of file
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