From 09d21f3f9f440812049746f0573cfa7f6aa8c7e5 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sat, 12 Jul 2008 03:20:57 +0000 Subject: THe redirect-on-slash story isn't part of the publisher. --- repoze/bfg/router.py | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'repoze/bfg/router.py') diff --git a/repoze/bfg/router.py b/repoze/bfg/router.py index bd7df2c94..56a692856 100644 --- a/repoze/bfg/router.py +++ b/repoze/bfg/router.py @@ -15,9 +15,8 @@ from repoze.bfg.interfaces import IRequest _marker = () class Router: - def __init__(self, root_policy, default_redirects=True): + def __init__(self, root_policy): self.root_policy = root_policy - self.default_redirects = default_redirects def __call__(self, environ, start_response): request = Request(environ) @@ -26,27 +25,20 @@ class Router: path = environ.get('PATH_INFO', '/') traverser = getMultiAdapter((root, request), IPublishTraverserFactory) context, name, subpath = traverser(path) - if self.default_redirects and (not name) and (not path.endswith('/')): - # if this is the default view of the context, and the URL - # doesn't end in a slash, redirect to the url + '/' (so we - # don't have to play base tag games) - app = HTTPFound(add_slash=True) + request.subpath = subpath + request.view_name = name + app = queryMultiAdapter((context, request), IViewFactory, name=name, + default=_marker) + if app is _marker: + app = HTTPNotFound(request.url) else: - request.subpath = subpath - request.view_name = name - app = queryMultiAdapter((context, request), IViewFactory, name=name, - default=_marker) - if app is _marker: - app = HTTPNotFound(request.url) - else: - app = getMultiAdapter((context, request, app), - IWSGIApplicationFactory) + app = getMultiAdapter((context, request, app), + IWSGIApplicationFactory) return app(environ, start_response) -def make_app(root_policy, package=None, default_redirects=True, - filename='configure.zcml'): +def make_app(root_policy, package=None, filename='configure.zcml'): import zope.configuration.xmlconfig zope.configuration.xmlconfig.file(filename, package=package) - return Router(root_policy, default_redirects) + return Router(root_policy) -- cgit v1.2.3