Mercurial > kallithea
comparison pylons_app/controllers/error.py @ 215:70f645fa97cc
Moved repo creation to admin/repos, as part of crud controller. Now repo creation is based on a form, which can be auto filled with data from 404 page. Fixed the error controller to properly give the repo name.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 24 May 2010 22:18:15 +0200 |
parents | b68b2246e5a6 |
children | 6ada8c223374 |
comparison
equal
deleted
inserted
replaced
214:5b8d00d40bd4 | 215:70f645fa97cc |
---|---|
6 from pylons.controllers.util import forward | 6 from pylons.controllers.util import forward |
7 from pylons.i18n.translation import _ | 7 from pylons.i18n.translation import _ |
8 from pylons_app.lib.base import BaseController, render | 8 from pylons_app.lib.base import BaseController, render |
9 from pylons.middleware import media_path | 9 from pylons.middleware import media_path |
10 from pylons_app.lib.utils import check_repo | 10 from pylons_app.lib.utils import check_repo |
11 from pylons_app.lib.filters import clean_repo | |
12 log = logging.getLogger(__name__) | |
11 | 13 |
12 log = logging.getLogger(__name__) | |
13 class ErrorController(BaseController): | 14 class ErrorController(BaseController): |
14 """ | 15 """ |
15 Generates error documents as and when they are required. | 16 Generates error documents as and when they are required. |
16 | 17 |
17 The ErrorDocuments middleware forwards to ErrorController when error | 18 The ErrorDocuments middleware forwards to ErrorController when error |
18 related status codes are returned from the application. | 19 related status codes are returned from the application. |
19 | 20 |
20 This behaviour can be altered by changing the parameters to the | 21 This behaviour can be altered by changing the parameters to the |
21 ErrorDocuments middleware in your config/middleware.py file. | 22 ErrorDocuments middleware in your config/middleware.py file. |
22 """ | 23 """ |
24 # def __before__(self): | |
25 # super(ErrorController, self).__before__() | |
23 | 26 |
24 def document(self): | 27 def document(self): |
25 resp = request.environ.get('pylons.original_response') | 28 resp = request.environ.get('pylons.original_response') |
29 | |
26 log.debug(resp.status) | 30 log.debug(resp.status) |
27 | 31 |
28 e = request.environ | 32 e = request.environ |
29 c.serv_p = r'%(protocol)s://%(host)s/' % { | 33 c.serv_p = r'%(protocol)s://%(host)s/' % { |
30 'protocol': e.get('wsgi.url_scheme'), | 34 'protocol': e.get('wsgi.url_scheme'), |
31 'host':e.get('HTTP_HOST'), | 35 'host':e.get('HTTP_HOST'), |
32 } | 36 } |
33 | 37 |
34 | 38 |
35 if resp.status_int == 404: | 39 if resp.status_int == 404: |
36 if check_repo(c.repo_name, g.base_path): | 40 org_e = request.environ.get('pylons.original_request').environ |
41 c.repo_name = repo_name = org_e['PATH_INFO'].split('/')[1] | |
42 c.repo_name_cleaned = clean_repo(c.repo_name) | |
43 if check_repo(repo_name, g.base_path): | |
37 return render('/errors/error_404.html') | 44 return render('/errors/error_404.html') |
38 | 45 |
39 c.error_message = cgi.escape(request.GET.get('code', str(resp.status))) | 46 c.error_message = cgi.escape(request.GET.get('code', str(resp.status))) |
40 c.error_explanation = self.get_error_explanation(resp.status_int) | 47 c.error_explanation = self.get_error_explanation(resp.status_int) |
41 | 48 |