diff options
author | Marcel Hellkamp <marc@gsites.de> | 2014-02-05 23:04:41 +0100 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2014-02-05 23:06:52 +0100 |
commit | 3cc83c6f2208847a93dae3e23a6615e41e0f541b (patch) | |
tree | 571ace968b71e1762aa7ed3178aa0cbc3db1030d | |
parent | 04340523ada2bb8beb7163303fd8fa275bc9420d (diff) | |
download | bottle-3cc83c6f2208847a93dae3e23a6615e41e0f541b.tar.gz |
fix #581: Mounted applications are shadowed by other routes.
This is a workaround, not really a fix. I'm working on a better solution.
-rw-r--r-- | bottle.py | 7 | ||||
-rw-r--r-- | test/test_mount.py | 10 |
2 files changed, 15 insertions, 2 deletions
@@ -411,7 +411,10 @@ class Router(object): verb = environ['REQUEST_METHOD'].upper() path = environ['PATH_INFO'] or '/' target = None - methods = [verb, 'GET', 'ANY'] if verb == 'HEAD' else [verb, 'ANY'] + if verb == 'HEAD': + methods = ['PROXY', verb, 'GET', 'ANY'] + else: + methods = ['PROXY', verb, 'ANY'] for method in methods: if method in self.static and path in self.static[method]: @@ -682,7 +685,7 @@ class Bottle(object): request.path_shift(-path_depth) options.setdefault('skip', True) - options.setdefault('method', 'ANY') + options.setdefault('method', 'PROXY') options.setdefault('mountpoint', {'prefix': prefix, 'target': app}) options['callback'] = mountpoint_wrapper diff --git a/test/test_mount.py b/test/test_mount.py index cf0684b..0065f20 100644 --- a/test/test_mount.py +++ b/test/test_mount.py @@ -11,6 +11,16 @@ class TestAppMounting(ServerTestBase): def test(test='foo'): return test + + def test_mount_order_bug581(self): + self.app.mount('/test/', self.subapp) + + # This should not match + self.app.route('/<test:path>', callback=lambda test: test) + + self.assertStatus(200, '/test/') + self.assertBody('foo', '/test/') + def test_mount(self): self.app.mount('/test/', self.subapp) self.assertStatus(404, '/') |