Hi, I am using web2 to run a cherrypy server at the root of the site using WSGI.
I've got a nearly working set up, the only problem is that when a request comes in for the root of the site, it gets redirected back to itself: % curl http://localhost:8080 This resource resides temporarily at <a href='http://localhost:8080/'> http://localhost:8080/</a> Intriguingly, if I request locations below the root, things work more OK: % curl http://localhost:8080/test/index then it works OK, even though I am registering the cherrypy at the root of the site. I've experimented, and if I register the cherrypy site in a subdir, everything works normally as expected! Here's the code that puts it at the root of the site. I've tested this code with a basic WSGI app, and it works OK. Only cherrypy seems to have this problem. One clue is that the logger shows that the URL being requested is '//' instead of '/': 2007-03-18 19:07:02-0700 [HTTPChannel,6,127.0.0.1] 127.0.0.1 - - [18/Mar/2007:19:07:02] "GET // HTTP/1.1" 302 97 "" "curl/7.15.1 (i686-suse-linux) libcurl/7.15.1 OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0" Here's the nearly working test example: from twisted.application import service, strports from twisted.web2 import server, channel from twisted.web2 import log from twisted.web2 import wsgi from twisted.web2.wsgi import WSGIResource from cherrypy._cpwsgi import wsgiApp import cherrypy ## Basic cherrypy index object that dumps the WSGI environment class Root(object): @cherrypy.expose def index(self): s = [] for key in cherrypy.request.wsgi_environ: s.append("%s=%s<br/>" % (key, cherrypy.request.wsgi_environ [key])) return "".join(s) ## Run this site using "twistd -noy" if __name__ == '__builtin__': ## Create an instance of the root object and mount it at / r = Root() cherrypy.tree.mount(r, '/') wsgi = wsgi.WSGIResource(wsgiApp) ## Set up the cherrypy environment cherrypy.config.update({ 'server.environment':'production', 'server.socketHost':'127.0.0.1', }) ## Start the cherrypy server; don't actually run an HTTP server, though cherrypy.server.start(initOnly=True, serverClass=None) ## Setup default common access logging res = log.LogWrapperResource(wsgi) log.DefaultCommonAccessLoggingObserver().start() # Create twisted web2 site site = server.Site(res) application = service.Application("demo") ## Launch the HTTP site at port 8080 s = strports.service('tcp:8080', channel.HTTPFactory(site)) s.setServiceParent(application)
_______________________________________________ Twisted-web mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
