[gen] Improvement in the management of Unauthorized exceptions.
This commit is contained in:
parent
0c50fe188a
commit
7049e4780e
|
@ -1136,13 +1136,22 @@ class ToolMixin(BaseMixin):
|
||||||
def manageError(self, error):
|
def manageError(self, error):
|
||||||
'''Manages an error.'''
|
'''Manages an error.'''
|
||||||
tb = sys.exc_info()
|
tb = sys.exc_info()
|
||||||
from zExceptions.ExceptionFormatter import format_exception
|
if error.type.__name__ == 'Unauthorized':
|
||||||
htmlMessage = format_exception(tb[0], tb[1], tb[2], as_html=1)
|
siteUrl = self.getSiteUrl()
|
||||||
textMessage = format_exception(tb[0], tb[1], tb[2], as_html=0)
|
htmlMessage = '<a href="%s"><img src="%s/ui/home.gif"/></a>' \
|
||||||
self.log(''.join(textMessage).strip(), type='error')
|
'You are not allowed to access this page.' % \
|
||||||
return '<table class="main" align="center" cellpadding="0"><tr>' \
|
(siteUrl, siteUrl)
|
||||||
'<td style="padding: 1em 1em 1em 1em">An error occurred. %s' \
|
userId = self.appy().user.getId() or 'system|anon'
|
||||||
'</td></tr></table>' % '\n'.join(htmlMessage)
|
textMessage = 'Unauthorized for %s @%s.' % \
|
||||||
|
(userId, self.REQUEST.get('PATH_INFO'))
|
||||||
|
else:
|
||||||
|
from zExceptions.ExceptionFormatter import format_exception
|
||||||
|
htmlMessage = format_exception(tb[0], tb[1], tb[2], as_html=1)
|
||||||
|
htmlMessage = '\n'.join(htmlMessage)
|
||||||
|
textMessage = format_exception(tb[0], tb[1], tb[2], as_html=0)
|
||||||
|
textMessage = ''.join(textMessage).strip()
|
||||||
|
self.log(textMessage, type='error')
|
||||||
|
return '<div class="error" align="center">%s</div>' % htmlMessage
|
||||||
|
|
||||||
def getMainPages(self):
|
def getMainPages(self):
|
||||||
'''Returns the main pages.'''
|
'''Returns the main pages.'''
|
||||||
|
|
|
@ -146,3 +146,4 @@ img { border: 0; vertical-align: middle }
|
||||||
.homeTable td { padding: 10px 5px 10px 10px }
|
.homeTable td { padding: 10px 5px 10px 10px }
|
||||||
.homeTable th { padding-top: 5px; font-size: 105% }
|
.homeTable th { padding-top: 5px; font-size: 105% }
|
||||||
.first { margin-top: 0px }
|
.first { margin-top: 0px }
|
||||||
|
.error { margin: 5px }
|
||||||
|
|
|
@ -118,8 +118,10 @@
|
||||||
</td>
|
</td>
|
||||||
<td tal:condition="not: isDataChange"
|
<td tal:condition="not: isDataChange"
|
||||||
tal:content="python: _(contextObj.getWorkflowLabel(event['action']))"/>
|
tal:content="python: _(contextObj.getWorkflowLabel(event['action']))"/>
|
||||||
<td tal:define="actorId python:event.get('actor')"
|
<td tal:define="actorId python:event.get('actor')">
|
||||||
tal:content="python: tool.getUserName(actorId)"/>
|
<span tal:condition="not: actorId" tal:replace="python: '?'"/>
|
||||||
|
<span tal:condition="actorId" tal:content="python: tool.getUserName(actorId)"></span>
|
||||||
|
</td>
|
||||||
<td tal:content="python: tool.formatDate(event['time'], withHour=True)"/>
|
<td tal:content="python: tool.formatDate(event['time'], withHour=True)"/>
|
||||||
<td tal:condition="not: isDataChange">
|
<td tal:condition="not: isDataChange">
|
||||||
<tal:c condition="rhComments"
|
<tal:c condition="rhComments"
|
||||||
|
|
Loading…
Reference in a new issue