[llvm-commits] [zorg] r146221 - /zorg/trunk/lnt/lnt/server/ui/app.py

Daniel Dunbar daniel at zuster.org
Thu Dec 8 17:19:45 PST 2011


Author: ddunbar
Date: Thu Dec  8 19:19:45 2011
New Revision: 146221

URL: http://llvm.org/viewvc/llvm-project?rev=146221&view=rev
Log:
lnt/server/ui: Add a fix for the missing root slash problem.

Modified:
    zorg/trunk/lnt/lnt/server/ui/app.py

Modified: zorg/trunk/lnt/lnt/server/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/app.py?rev=146221&r1=146220&r2=146221&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/app.py (original)
+++ zorg/trunk/lnt/lnt/server/ui/app.py Thu Dec  8 19:19:45 2011
@@ -17,6 +17,16 @@
 from lnt.db import perfdbsummary
 from lnt.db import perfdb
 
+class RootSlashPatchMiddleware(object):
+    def __init__(self, app):
+        self.app = app
+
+    def __call__(self, environ, start_response):
+        if environ['PATH_INFO'] == '':
+            return flask.redirect(environ['SCRIPT_NAME'] + '/')(
+                environ, start_response)
+        return self.app(environ, start_response)
+
 class Request(flask.Request):
     def __init__(self, *args, **kwargs):
         super(Request, self).__init__(*args, **kwargs)
@@ -83,6 +93,10 @@
         # Store a few global things we want available to templates.
         self.version = lnt.__version__
 
+        # Inject a fix for missing slashes on the root URL (see Flask issue
+        # #169).
+        self.wsgi_app = RootSlashPatchMiddleware(self.wsgi_app)
+
     def load_config(self, config_path):
         config_data = {}
         exec open(config_path) in config_data





More information about the llvm-commits mailing list