diff theslasher/__init__.py @ 0:3812c1493dde default tip

add the slasher...be afraid, be very afraid
author k0s <k0scist@gmail.com>
date Mon, 11 Jan 2010 17:50:36 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/theslasher/__init__.py	Mon Jan 11 17:50:36 2010 -0500
@@ -0,0 +1,22 @@
+"""
+request dispatcher
+"""
+
+from webob import Request, exc
+
+class TheSlasher(object):
+
+    ### class level variables
+    def __init__(self, app):
+        self.app = app
+
+    ### methods dealing with HTTP
+    def __call__(self, environ, start_response):
+        
+        request = Request(environ)
+
+        if request.path_info.endswith('/') and (request.path_info != '/'):
+            location = request.path_info.rstrip('/')
+            return exc.HTTPMovedPermanently(location=location)(environ, start_response)
+
+        return self.app(environ, start_response)