Commit 4e9ebe02 authored by Romain Courteaud's avatar Romain Courteaud

Catch Unauthorized exception which may be raised by index_html (through...

Catch Unauthorized exception which may be raised by index_html (through checkConversionFormatPermission script), and return a nicer message to the user.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21269 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b47b6eec
......@@ -73,7 +73,14 @@ output (a file in desired format).\n
request = context.REQUEST\n
response = request.RESPONSE\n
\n
data = context.index_html(request, response, format=format, force=force)\n
from zExceptions import Unauthorized\n
\n
try:\n
data = context.index_html(request, response, format=format, force=force)\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
typ = response.headers.get(\'content-type\')\n
\n
if not filename:\n
......@@ -143,7 +150,11 @@ return data\n
<string>context</string>
<string>request</string>
<string>response</string>
<string>zExceptions</string>
<string>Unauthorized</string>
<string>data</string>
<string>msg</string>
<string>dict</string>
<string>typ</string>
<string>_getitem_</string>
<string>_inplacevar_</string>
......
10
\ No newline at end of file
11
\ No newline at end of file
......@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
......@@ -71,6 +68,14 @@
<value> <string>request = container.REQUEST\n
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
......@@ -78,7 +83,8 @@ else:\n
\n
file_name = context.getSourceReference() or context.getTitle() or context.getId()\n
response.setHeader(\'Content-disposition\', \'attachment; filename="%s"\' % file_name)\n
return context.index_html(request, response)\n
\n
return result\n
</string> </value>
</item>
<item>
......@@ -125,8 +131,13 @@ return context.index_html(request, response)\n
<string>container</string>
<string>request</string>
<string>response</string>
<string>hasattr</string>
<string>zExceptions</string>
<string>Unauthorized</string>
<string>context</string>
<string>result</string>
<string>msg</string>
<string>dict</string>
<string>hasattr</string>
<string>file_name</string>
</tuple>
</value>
......
826
\ No newline at end of file
827
\ 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