Issue #1288 resolved

cherrypy.lib.static serve_file doesn't work with _cpconfig.error_page

edibleenergy
created an issue

Test case:

import cherrypy
from cherrypy.lib.static import serve_file
class HelloWorld(object):
    def index(self):
        raise cherrypy.HTTPError(404, 'Not Found')
        return "Hello world!"
    index.exposed = True
def error_page_404(status, message, traceback, version):
    return serve_file('/home/myhome/qa/404.html',content_type='text/html')
cherrypy.config.update({'error_page.404': error_page_404})
cherrypy.quickstart(HelloWorld())

Yields:

11/Feb/2014:19:46:56] ENGINE Started monitor thread 'Autoreloader'.
[11/Feb/2014:19:46:56] ENGINE Started monitor thread '_TimeoutMonitor'.
[11/Feb/2014:19:46:56] ENGINE Serving on 127.0.0.1:8080
[11/Feb/2014:19:46:56] ENGINE Bus STARTED
[11/Feb/2014:19:46:58] TOOLS.ENCODE Replacing request.handler
[11/Feb/2014:19:46:58] HTTP Traceback (most recent call last):
  File "/home/skaufman/env/local/lib/python2.7/site-packages/cherrypy/_cprequest.py", line 664, in respond
    inst.set_response()
  File "/home/skaufman/env/local/lib/python2.7/site-packages/cherrypy/_cperror.py", line 376, in set_response
    message=self._message).encode('utf-8')
AttributeError: 'file_generator' object has no attribute 'encode'

Comments (3)

  1. Log in to comment