comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:3812c1493dde
1 """
2 request dispatcher
3 """
4
5 from webob import Request, exc
6
7 class TheSlasher(object):
8
9 ### class level variables
10 def __init__(self, app):
11 self.app = app
12
13 ### methods dealing with HTTP
14 def __call__(self, environ, start_response):
15
16 request = Request(environ)
17
18 if request.path_info.endswith('/') and (request.path_info != '/'):
19 location = request.path_info.rstrip('/')
20 return exc.HTTPMovedPermanently(location=location)(environ, start_response)
21
22 return self.app(environ, start_response)