Skip to content

Commit

Permalink
Patches for error files to serve from a zip-file
Browse files Browse the repository at this point in the history
--HG--
branch : trunk
  • Loading branch information
bbangert committed Oct 29, 2008
1 parent 83cead4 commit 1494aaf
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cgi
import os.path

from paste.urlparser import StaticURLParser
from paste.urlparser import PkgResourcesParser
from pylons import request
from pylons.controllers.util import forward
from pylons.middleware import error_document_template, media_path
Expand Down Expand Up @@ -31,16 +31,16 @@ class ErrorController(BaseController):

def img(self, id):
"""Serve Pylons' stock images"""
return self._serve_file(os.path.join(media_path, 'img'), id)
return self._serve_file('/'.join(['media/img', id]))

def style(self, id):
"""Serve Pylons' stock stylesheets"""
return self._serve_file(os.path.join(media_path, 'style'), id)
return self._serve_file('/'.join(['media/style', id]))

def _serve_file(self, root, path):
def _serve_file(self, path):
"""Call Paste's FileApp (a WSGI application) to serve the file
at the specified path
"""
static = StaticURLParser(root)
static = PkgResourcesParser('pylons', 'pylons')
request.environ['PATH_INFO'] = '/%s' % path
return static(request.environ, self.start_response)

0 comments on commit 1494aaf

Please sign in to comment.