# HG changeset patch # User Marcin Kuzminski # Date 1291919536 -3600 # Node ID 81e8dfa3beb5ccd6ab3fc71e8bccd6e67c90ee05 # Parent f579790a0ecd503fcda4780b663b5459b3613676# Parent d5a71348ee4de9b2b77d9447e163196fe7f9b43c merge diff -r d5a71348ee4d -r 81e8dfa3beb5 rhodecode/controllers/error.py --- a/rhodecode/controllers/error.py Thu Dec 09 19:07:57 2010 +0100 +++ b/rhodecode/controllers/error.py Thu Dec 09 19:32:16 2010 +0100 @@ -1,33 +1,58 @@ -import logging +# -*- coding: utf-8 -*- +""" + package.rhodecode.controllers.error + ~~~~~~~~~~~~~~ + + RhodeCode error controller + + :created_on: Dec 8, 2010 + :author: marcink + :copyright: (C) 2009-2010 Marcin Kuzminski + :license: GPLv3, see COPYING for more details. +""" +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; version 2 +# of the License or (at your opinion) any later version of the license. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +import os import cgi -import os +import logging import paste.fileapp -from pylons import tmpl_context as c, app_globals as g, request, config -from pylons.controllers.util import forward + +from pylons import tmpl_context as c, request from pylons.i18n.translation import _ +from pylons.middleware import media_path + from rhodecode.lib.base import BaseController, render -from pylons.middleware import media_path -from rhodecode.lib.utils import check_repo -import rhodecode.lib.helpers as h -from rhodecode import __version__ + log = logging.getLogger(__name__) class ErrorController(BaseController): - """ - Generates error documents as and when they are required. + """Generates error documents as and when they are required. The ErrorDocuments middleware forwards to ErrorController when error related status codes are returned from the application. - This behaviour can be altered by changing the parameters to the + This behavior can be altered by changing the parameters to the ErrorDocuments middleware in your config/middleware.py file. """ + def __before__(self): pass#disable all base actions since we don't need them here - + def document(self): resp = request.environ.get('pylons.original_response') - + log.debug('### %s ###', resp.status) e = request.environ @@ -36,7 +61,7 @@ 'host':e.get('HTTP_HOST'), } - + c.error_message = cgi.escape(request.GET.get('code', str(resp.status))) c.error_explanation = self.get_error_explanation(resp.status_int) @@ -74,7 +99,7 @@ if code == 400: return _('The request could not be understood by the server due to malformed syntax.') if code == 401: - return _('Unathorized access to resource') + return _('Unauthorized access to resource') if code == 403: return _("You don't have permission to view this page") if code == 404: