summaryrefslogtreecommitdiff
path: root/fixers.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2013-04-15 10:45:52 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2013-04-15 10:45:52 +0200
commit993b735921689ef7a3aa646e735f9f5223829dae (patch)
tree0013e7618da29bf3849d9acf0674c6700cfcb796 /fixers.py
parentb1f11c01d05a05f1e55ec6fb8215e668c102361c (diff)
downloadkosten-993b735921689ef7a3aa646e735f9f5223829dae.tar.gz
kosten-993b735921689ef7a3aa646e735f9f5223829dae.tar.bz2
kosten-993b735921689ef7a3aa646e735f9f5223829dae.zip
Some request fixers
Diffstat (limited to 'fixers.py')
-rw-r--r--fixers.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/fixers.py b/fixers.py
new file mode 100644
index 0000000..deded63
--- /dev/null
+++ b/fixers.py
@@ -0,0 +1,22 @@
+from werkzeug.wrappers import BaseResponse as Response
+
+class ScriptNameFixer(object):
+ """Sets SCRIPT_NAME from REQUEST_URI."""
+
+ def __init__ (self, app):
+ self.app = app
+
+ def __call__ (self, environ, start_response):
+ uri = environ["REQUEST_URI"]
+ path = environ["PATH_INFO"]
+
+ if uri.endswith(path):
+ environ["SCRIPT_NAME"] = uri[:-len(path)]
+
+ return self.app(environ, start_response)
+
+def EnvironApp(environ, start_response):
+ """Returns the WSGI environment as response."""
+
+ r = Response(str(environ))
+ return r(environ, start_response)