Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #455: test_new_wsgiserver.py

Line 
1 import sys
2
3 import cherrypy
4 from cherrypy._cpwsgi import wsgiApp
5 from paste.evalexception.middleware import EvalException
6
7
8 class AppRoot:
9     @cherrypy.expose
10     def default(self, *args, **params):
11         if 'error' in args:
12             raise Exception, "You asked for it in CherryPy this time!"
13         yield "Hello, world!<br>"
14         keys = cherrypy.request.wsgi_environ.keys()
15         keys.sort()
16         for k in keys:
17             yield "%s = %s<br>" % (k, cherrypy.request.wsgi_environ[k])
18
19 if 'new_stuff' in sys.argv:
20     error_checking_app = EvalException(simple_app, global_conf={})
21     error_checking_cp_app = EvalException(wsgiApp, global_conf={})
22
23     cherrypy.tree.mount(AppRoot(), '/')
24     #cherrypy.tree.mount(AppRoot(), '/right/here')
25
26     #cherrypy.server.cp_mount_point = '/right/here'
27     cherrypy.server.cp_wsgi_app = error_checking_cp_app
28
29
30     cherrypy.config.update({'server.throw_errors':True})
31
32 else:
33     cherrypy.tree.mount(AppRoot(), '/')
34     cherrypy.tree.mount(AppRoot(), '/right/here')
35
36
37 cherrypy.server.start()
38

Hosted by WebFaction

Log in as guest/cpguest to create tickets