vigiboard / vigiboard / controllers / error.py @ ee3ae8c8
History | View | Annotate | Download (1.06 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
"""Error controller"""
|
3 |
|
4 |
from tg import request, expose |
5 |
from pylons.i18n import ugettext as _ |
6 |
|
7 |
__all__ = ['ErrorController']
|
8 |
|
9 |
|
10 |
class ErrorController(object): |
11 |
"""
|
12 |
Generates error documents as and when they are required.
|
13 |
|
14 |
The ErrorDocuments middleware forwards to ErrorController when error
|
15 |
related status codes are returned from the application.
|
16 |
|
17 |
This behaviour can be altered by changing the parameters to the
|
18 |
ErrorDocuments middleware in your config/middleware.py file.
|
19 |
|
20 |
"""
|
21 |
|
22 |
@expose('error.html') |
23 |
def document(self, *args, **kwargs): |
24 |
"""Render the error document"""
|
25 |
resp = request.environ.get('pylons.original_response')
|
26 |
default_message = ("<p>" + _("We're sorry but we weren't " + |
27 |
"able to process this request.") + "</p>") |
28 |
values = dict(prefix=request.environ.get('SCRIPT_NAME', ''), |
29 |
code=int(request.params.get('code', resp.status_int)), |
30 |
message=request.params.get('message', default_message))
|
31 |
return values
|