Changeset 1470
- Timestamp:
- 12/03/06 05:31:25
- Files:
-
- trunk/cherrypy/_cpdispatch.py (modified) (1 diff)
- trunk/cherrypy/_cprequest.py (modified) (1 diff)
- trunk/cherrypy/test/test_virtualhost.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cpdispatch.py
r1467 r1470 350 350 path_info = http.urljoin(prefix, path_info) 351 351 352 return next_dispatcher(path_info) 352 result = next_dispatcher(path_info) 353 354 # Touch up staticdir config. See http://www.cherrypy.org/ticket/614. 355 section = cherrypy.request.config.get('tools.staticdir.section') 356 if section: 357 section = section[len(prefix):] 358 cherrypy.request.config['tools.staticdir.section'] = section 359 360 return result 353 361 return vhost_dispatch 354 362 trunk/cherrypy/_cprequest.py
r1469 r1470 179 179 "response": response_namespace, 180 180 "error_page": error_page_namespace, 181 # "tools": See _cptools.Toolbox 181 182 } 182 183 trunk/cherrypy/test/test_virtualhost.py
r1453 r1470 6 6 7 7 import cherrypy 8 from cherrypy import _cpdispatch9 8 10 9 def setup_server(): … … 38 37 url.exposed = True 39 38 39 # Test static as a handler (section must NOT include vhost prefix) 40 40 static = cherrypy.tools.staticdir.handler(section='/static', dir=curdir) 41 42 41 43 42 root = Root() 44 43 root.mydom2 = VHost("Domain 2") 45 44 root.mydom3 = VHost("Domain 3") 46 cherrypy.tree.mount(root, config={'/': { 47 'request.dispatch': _cpdispatch.VirtualHost( 48 **{'www.mydom2.com': '/mydom2', 45 hostmap = {'www.mydom2.com': '/mydom2', 49 46 'www.mydom3.com': '/mydom3', 50 47 'www.mydom4.com': '/dom4', 51 }), 52 }}) 48 } 49 cherrypy.tree.mount(root, config={ 50 '/': {'request.dispatch': cherrypy.dispatch.VirtualHost(**hostmap)}, 51 # Test static in config (section must include vhost prefix) 52 '/mydom2/static2': {'tools.staticdir.on': True, 53 'tools.staticdir.root': curdir, 54 'tools.staticdir.dir': 'static', 55 'tools.staticdir.index': 'index.html', 56 }, 57 }) 53 58 54 59 cherrypy.config.update({'environment': 'test_suite'}) … … 87 92 88 93 def test_VHost_plus_Static(self): 94 # Test static as a handler 89 95 self.getPage("/static/style.css", [('Host', 'www.mydom2.com')]) 90 96 self.assertStatus('200 OK') 91 97 self.assertHeader('Content-Type', 'text/css') 98 99 # Test static in config 100 self.getPage("/static2/dirback.jpg", [('Host', 'www.mydom2.com')]) 101 self.assertStatus('200 OK') 102 self.assertHeader('Content-Type', 'image/jpeg') 103 104 # Test static config with "index" arg 105 self.getPage("/static2/", [('Host', 'www.mydom2.com')]) 106 self.assertStatus('200 OK') 107 self.assertBody('Hello, world\r\n') 108 self.getPage("/static2", [('Host', 'www.mydom2.com')]) 109 self.assertStatus('200 OK') 110 self.assertBody('Hello, world\r\n') 92 111 93 112

