I used to use cherrypy with mod_python and I built my controller trees with cherrypy.tree.mount
calls and I would like to keep them (they are spread through the code).
Now I have to use mod_wsgi. Example: from cherrypy wiki
import sys
sys.stdout = sys.stderr
import atexit
import threading
import cherrypy
cherrypy.config.update({'environment': 'embedded'})
if cherrypy.__version__.startswith('3.0') and cherrypy.engine.state == 0:
cherrypy.engine.start(blocking=False)
atexit.register(cherrypy.engine.stop)
class Root(object):
def index(self):
return 'Hello World!'
index.exposed = True
application = cherrypy.Application(Root(), script_name=None, config=None)
My problem is that every cherrypy.tree.mount
call creates a cherrypy.Application
. And mod_wsgi wants one object named 'application'
.
I know that you can build a cherrypy tree with class variables but I don't want to do that.
Is there a way to use cherrypy.tree.mount
and get one application object?
There is also cherrypy.tree.graft but I think it's meant for a different purpose.
Finally! Got it myself - from the manual...
cherrypy.tree
is itself a WSGI object so you simply do:
cherrypy.tree.mount(...)
cherrypy.tree.mount(...)
cherrypy.tree.mount(...)
application = cherrypy.tree
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With