Mercurial > public > src > rhodecode
diff pylons_app/controllers/error.py @ 125:2811259dc12d
Moved check_repo function to utils, error controller check for first name in url, for this repo and only prints 404 make repo template if repo does not exists, moded check repo from admin
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 29 Apr 2010 01:26:20 +0200 |
parents | 8b06c420491d |
children | b68b2246e5a6 |
line wrap: on
line diff
--- a/pylons_app/controllers/error.py Thu Apr 29 00:29:49 2010 +0200 +++ b/pylons_app/controllers/error.py Thu Apr 29 01:26:20 2010 +0200 @@ -1,13 +1,13 @@ import logging -from paste.urlparser import PkgResourcesParser +import cgi +import os import paste.fileapp from pylons import tmpl_context as c, app_globals as g, request, config from pylons.controllers.util import forward from pylons.i18n.translation import _ from pylons_app.lib.base import BaseController, render -from pylons.middleware import error_document_template, media_path -import cgi -import os +from pylons.middleware import media_path +from pylons_app.lib.utils import check_repo log = logging.getLogger(__name__) class ErrorController(BaseController): @@ -25,7 +25,7 @@ c.repos_prefix = config['repos_name'] c.repo_name = request.environ['pylons.original_request']\ - .environ.get('PATH_INFO').split('/')[-1] + .environ.get('PATH_INFO').split('/')[1] def document(self): resp = request.environ.get('pylons.original_response') @@ -36,9 +36,11 @@ 'protocol': e.get('wsgi.url_scheme'), 'host':e.get('HTTP_HOST'), } - + + if resp.status_int == 404: - return render('/errors/error_404.html') + if check_repo(c.repo_name, g.base_path): + return render('/errors/error_404.html') c.error_message = cgi.escape(request.GET.get('code', str(resp.status))) c.error_explanation = self.get_error_explanation(resp.status_int)