#86: Nicer error handler for quickstarted projects
------------------------+---------------------------------------------------
 Reporter:  kevin       |        Owner:     
     Type:  defect      |       Status:  new
 Priority:  normal      |    Milestone:  1.1
Component:  TurboGears  |      Version:     
 Severity:  normal      |   Resolution:     
 Keywords:              |  
------------------------+---------------------------------------------------
Comment (by mgood):

 I've added `EvalException` to my `start-package.py` file based on the
 CherryPy example.  Simply replace the last line
 (`cherrypy.server.start()`) with:

 {{{
 #!python
 from cherrypy._cpwsgi import wsgiApp, CPHTTPRequest
 from cherrypy._cpwsgiserver import CherryPyWSGIServer

 class SimpleWSGIServer(CherryPyWSGIServer):
     """A WSGI server that accepts a WSGI application as a parameter."""
     RequestHandlerClass = CPHTTPRequest

     def __init__(self):
         conf = cherrypy.config.get
         wsgi_app = wsgiApp
         if conf('server.environment') == 'development':
             try:
                 from paste.evalexception.middleware import EvalException
             except ImportError:
                 pass
             else:
                 wsgi_app = EvalException(wsgi_app, global_conf={})
                 cherrypy.config.update({'server.throw_errors':True})
         bind_addr = (conf("server.socket_host"),
 conf("server.socket_port"))
         CherryPyWSGIServer.__init__(self, bind_addr, wsgi_app,
                                     conf("server.thread_pool"),
                                     conf("server.socket_host"),
                                     request_queue_size = conf(
                                         "server.socket_queue_size"),
                                     )

 cherrypy.server.start(server=SimpleWSGIServer())
 }}}

 The `EvalException` middleware is only enabled in development mode, and
 ignores it if Paste is not installed.

-- 
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/86>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---

Reply via email to