License New BSD license
Lines 7
Keywords
middleware (5) Pylons (10) trailing slash (1)
Included in this Library
Permissions
Viewable by Everyone
Editable by All Siafoo Users
Hide
Bored? Check out the Recent Activity on Siafoo Join Siafoo Now or Learn More

Pylons Middleware to Strip a Trailing Slash Atom Feed 0

In Brief You can use this middleware to strip a trailing slash from the request, since the new Routes doesn't seem to like them. You should probably do this at the very bottom of your middleware.py, before it returns, so this will be the first middleware the request gets to:... more
# 's
1class StripTrailingSlash(object):
2 def __init__(self, app):
3 self.app = app
4
5 def __call__(self, environ, start_response):
6 environ['PATH_INFO'] = environ.get('PATH_INFO', '').rstrip('/')
7 return self.app(environ, start_response)

You can use this middleware to strip a trailing slash from the request, since the new Routes doesn't seem to like them. You should probably do this at the very bottom of your middleware.py, before it returns, so this will be the first middleware the request gets to:

# 's
1app = StripTrailingSlash(app)