diff options
| author | Chris McDonough <chrism@agendaless.com> | 2008-07-12 03:20:57 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2008-07-12 03:20:57 +0000 |
| commit | 09d21f3f9f440812049746f0573cfa7f6aa8c7e5 (patch) | |
| tree | 03f7449bb205261cc04c77c604d6306e46c87b9f /repoze/bfg/router.py | |
| parent | 2d74688f6564c325077044c4b870c6f966baad91 (diff) | |
| download | pyramid-09d21f3f9f440812049746f0573cfa7f6aa8c7e5.tar.gz pyramid-09d21f3f9f440812049746f0573cfa7f6aa8c7e5.tar.bz2 pyramid-09d21f3f9f440812049746f0573cfa7f6aa8c7e5.zip | |
THe redirect-on-slash story isn't part of the publisher.
Diffstat (limited to 'repoze/bfg/router.py')
| -rw-r--r-- | repoze/bfg/router.py | 30 |
1 files changed, 11 insertions, 19 deletions
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) |
