<br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><br>Which version of cherrypy are you using? I did an easy_install<br>cherrypy and got
3.0.1 but your code didn't work on it. wsgiApp is<br>somewhere else now or something.</blockquote><div><br><br>OK, I've updated my test example to work with CherryPy 3.0. This works a bit better,<br>in fact, when I visit the root of the site I get my cherrypy application! Since
<br>I'm not tied to CherryPy 2.2 (unless TurboGears requires it) this 'fixes' most of my problem.<br>I'm still having a problem if I access some URLs under the root, but I have yet to determine if it's going
<br>to be a problem.<br><br>Here's a CherryPy 3.0.1 application that works with Twisted web2 using the WSGI app support.<br><br>from twisted.internet import reactor<br>from twisted.application import service, strports
<br>from twisted.web2 import server, channel<br>from twisted.web2 import log<br>from twisted.web2 import wsgi<br>from twisted.web2.wsgi import WSGIResource<br>import cherrypy<br><br>## Basic cherrypy index object that dumps the WSGI environment
<br>class Root(object):<br> @cherrypy.expose<br> def index(self):<br> s = []<br> for key in cherrypy.request.wsgi_environ:<br> s.append("%s=%s<br/>" % (key, cherrypy.request.wsgi_environ
[key]))<br><br> return "".join(s)<br><br>## Create an instance of the root application and mount it at /<br>r = Root()<br><br>## Convert the Root application to a hostable WSGI application<br>cpwsgiapp =
cherrypy.Application(Root(), '/')<br><br>## Convert the CherryPy WSGI app to a Twisted WSGI resource<br>wsgi = wsgi.WSGIResource(cpwsgiapp)<br><br>## Set up the cherrypy environment<br>cherrypy.config.update({<br>
'server.environment':'production',<br> })<br><br>## Start the cherrypy engine without starting a blocking server<br>cherrypy.engine.start(blocking=False)<br><br>## Setup default common access logging
<br>res = log.LogWrapperResource(wsgi)<br>log.DefaultCommonAccessLoggingObserver().start()<br><br># Create twisted web2 site<br>site = server.Site(res)<br><br>## Launch the HTTP site at port 8080<br><br>## code path invoked by twistd
<br>if __name__ == '__builtin__':<br> application = service.Application("demo")<br> s = strports.service('tcp:8080', channel.HTTPFactory(site))<br> s.setServiceParent(application)<br><br>
## code path when run directly<br>if __name__ == '__main__':<br> from twisted.python import log as pythonlog<br> import sys<br> pythonlog.startLogging(sys.stdout)<br> reactor.listenTCP(8080, channel.HTTPFactory
(site))<br> reactor.run()<br><br></div><br></div><br>