proxy: Make sure root pages get the right theme. master
authorMatthijs Kooijman <matthijs@stdin.nl>
Thu, 21 Jul 2011 16:20:42 +0000 (18:20 +0200)
committerMatthijs Kooijman <matthijs@stdin.nl>
Thu, 21 Jul 2011 16:20:42 +0000 (18:20 +0200)
Previously, a theme prefix of /Site/ would not match /Site. This is now
fixed.

plugin/theme/proxy.py

index 58e4ab2d89fb47f7059603bbb43356f8b3459d36..8aa3a24092ce9a5abfc9e6917e8c76e7b5057bc5 100644 (file)
@@ -33,8 +33,14 @@ def Theme(context):
     called.  Instead, we define a Theme function that calls the proper
     constructor.
     """
+    path = context.request.path
+    # Always add a trailing space, so that a /Foo/ also matches the /Foo
+    # path (without needing to remove the trailing space from the
+    # prefix, which would make also match /FooBar).
+    if path[-1] != '/':
+        path += '/'
     for (prefix, theme) in context.cfg.proxy_theme_mapping:
-        if context.request.path.startswith(prefix):
+        if path.startswith(prefix):
             return load_theme(context, theme)
 
     raise ThemeNotFound("proxy_theme_mapping defines no theme for url: %s" % (context.request.path))