]>
gitweb.michael.orlitzky.com - dead/census-tools.git/blob - www/maps/maps/controllers/error.py
3 from paste
.urlparser
import PkgResourcesParser
4 from pylons
import request
5 from pylons
.controllers
.util
import forward
6 from pylons
.middleware
import error_document_template
7 from webhelpers
.html
.builder
import literal
9 from maps
.lib
.base
import BaseController
11 class ErrorController(BaseController
):
13 """Generates error documents as and when they are required.
15 The ErrorDocuments middleware forwards to ErrorController when error
16 related status codes are returned from the application.
18 This behaviour can be altered by changing the parameters to the
19 ErrorDocuments middleware in your config/middleware.py file.
24 """Render the error document"""
25 resp
= request
.environ
.get('pylons.original_response')
26 content
= literal(resp
.body
) or cgi
.escape(request
.GET
.get('message', ''))
27 page
= error_document_template
% \
28 dict(prefix
=request
.environ
.get('SCRIPT_NAME', ''),
29 code
=cgi
.escape(request
.GET
.get('code', str(resp
.status_int
))),
34 """Serve Pylons' stock images"""
35 return self
._serve
_file
('/'.join(['media/img', id]))
38 """Serve Pylons' stock stylesheets"""
39 return self
._serve
_file
('/'.join(['media/style', id]))
41 def _serve_file(self
, path
):
42 """Call Paste's FileApp (a WSGI application) to serve the file
45 request
.environ
['PATH_INFO'] = '/%s' % path
46 return forward(PkgResourcesParser('pylons', 'pylons'))