Ticket #614 (defect)
Opened 2 years ago
Last modified 2 years ago
_cpdispatch.VirtualHost and staticdir tool still don't play well together
Status: closed (fixed)
| Reported by: | ricardo | Assigned to: | rdelon |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | CherryPy code | Keywords: | |
| Cc: |
In response to #607 you suggested upgrading to 3.0.0RC1, because under this version the test configuration specified in that ticket would work. I have upgraded but the configuration still doesn't work for me. And looking deeper into the code, I don't understand how it can be working for you.
Here is the code I'm now using:
import cherrypy from cherrypy import _cpdispatch class Root: pass conf = {'/': {'server.socket_port': 80, 'request.dispatch': _cpdispatch.VirtualHost( **{'mpp.net': '/mpp'}), 'tools.staticdir.root': '/home/user/sites', }, '/mpp': {'tools.staticdir.on': True, 'tools.staticdir.index': 'index.htm', 'tools.staticdir.dir': 'mpp' } } cherrypy.quickstart(Root(), '/', config = conf)
With this code, when I browse to http://mpp.net/index.htm, vhost_dispatch in _cpdispatch.VirtualHost? correctly prepends '/mpp' to a path_info variable of '/index.htm'. But when staticdir later constructs a branch variable, it doesn't draw upon the path_info variable as reconstructed by _cpdispatch; instead it works with the value of that variable stored in cherrypy.request.path_info, which (at least for me) is still just '/index.htm'. So staticdir ends up setting the branch variable to 'x.htm', meaning of course that cherrypy fails to find the resulting filename.
Or maybe I'm just failing to understand how properly to set up my configuration?
Change History
12/02/06 05:09:25: Modified by ricardo
12/02/06 11:41:03: Modified by fumanchu
- description changed.
12/03/06 05:37:49: Modified by fumanchu
- status changed from new to closed.
- resolution set to fixed.
Fixed in [1470]. My earlier test worked because I was using staticdir as a handler, in which case the 'section' arg should not include the virtual host prefix. When specifying staticdir in a config dict or file, the [/section] arg must include the virtual host prefix. See source:trunk/cherrypy/test/test_virtualhost.py for complete examples.
Note that you can also now write cherrypy.dispatch.VirtualHost instead of importing _cpdispatch.


Sorry, I meant in response to ticket 607...