In Pyramid, add_notfound_view(append_slash=True) will cause a request which does not match any view, but which would match a view if a trailing slash existed on the end, to be redirected to the matching view.
Does an inverse to this exist? That is: If I have a route configured as
config.add_route('list_reports', '/reports')
and a user requests /reports/, is there a simple way to cause them to be redirected appropriately?
The non-global solution
Add a second route for each view that you want redirected.
Globally redirect all routes (never support slash-appended routes)
Simply rewrite the URLs. This can be done via pyramid_rewrite, or externally by your web server.
Attempt to redirect if a route is not found
Rip the
AppendSlashNotFoundFactoryout of pyramid’s source and invert it. Sorry, not doing that one for you here, but just as easy.