##// END OF EJS Templates
spelling fixes for error controller
marcink -
r819:f579790a beta
parent child Browse files
Show More
@@ -1,33 +1,58 b''
1 import logging
1 # -*- coding: utf-8 -*-
2 """
3 package.rhodecode.controllers.error
4 ~~~~~~~~~~~~~~
5
6 RhodeCode error controller
7
8 :created_on: Dec 8, 2010
9 :author: marcink
10 :copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
12 """
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License
15 # as published by the Free Software Foundation; version 2
16 # of the License or (at your opinion) any later version of the license.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26 # MA 02110-1301, USA.
27 import os
2 import cgi
28 import cgi
3 import os
29 import logging
4 import paste.fileapp
30 import paste.fileapp
5 from pylons import tmpl_context as c, app_globals as g, request, config
31
6 from pylons.controllers.util import forward
32 from pylons import tmpl_context as c, request
7 from pylons.i18n.translation import _
33 from pylons.i18n.translation import _
34 from pylons.middleware import media_path
35
8 from rhodecode.lib.base import BaseController, render
36 from rhodecode.lib.base import BaseController, render
9 from pylons.middleware import media_path
37
10 from rhodecode.lib.utils import check_repo
11 import rhodecode.lib.helpers as h
12 from rhodecode import __version__
13 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
14
39
15 class ErrorController(BaseController):
40 class ErrorController(BaseController):
16 """
41 """Generates error documents as and when they are required.
17 Generates error documents as and when they are required.
18
42
19 The ErrorDocuments middleware forwards to ErrorController when error
43 The ErrorDocuments middleware forwards to ErrorController when error
20 related status codes are returned from the application.
44 related status codes are returned from the application.
21
45
22 This behaviour can be altered by changing the parameters to the
46 This behavior can be altered by changing the parameters to the
23 ErrorDocuments middleware in your config/middleware.py file.
47 ErrorDocuments middleware in your config/middleware.py file.
24 """
48 """
49
25 def __before__(self):
50 def __before__(self):
26 pass#disable all base actions since we don't need them here
51 pass#disable all base actions since we don't need them here
27
52
28 def document(self):
53 def document(self):
29 resp = request.environ.get('pylons.original_response')
54 resp = request.environ.get('pylons.original_response')
30
55
31 log.debug('### %s ###', resp.status)
56 log.debug('### %s ###', resp.status)
32
57
33 e = request.environ
58 e = request.environ
@@ -36,7 +61,7 b' class ErrorController(BaseController):'
36 'host':e.get('HTTP_HOST'),
61 'host':e.get('HTTP_HOST'),
37 }
62 }
38
63
39
64
40 c.error_message = cgi.escape(request.GET.get('code', str(resp.status)))
65 c.error_message = cgi.escape(request.GET.get('code', str(resp.status)))
41 c.error_explanation = self.get_error_explanation(resp.status_int)
66 c.error_explanation = self.get_error_explanation(resp.status_int)
42
67
@@ -74,7 +99,7 b' class ErrorController(BaseController):'
74 if code == 400:
99 if code == 400:
75 return _('The request could not be understood by the server due to malformed syntax.')
100 return _('The request could not be understood by the server due to malformed syntax.')
76 if code == 401:
101 if code == 401:
77 return _('Unathorized access to resource')
102 return _('Unauthorized access to resource')
78 if code == 403:
103 if code == 403:
79 return _("You don't have permission to view this page")
104 return _("You don't have permission to view this page")
80 if code == 404:
105 if code == 404:
General Comments 0
You need to be logged in to leave comments. Login now