- # No matching page?
- if route_match is None:
- # Try to do see if we have a match with a trailing slash
- # added and if so, redirect
- if not path_info.endswith('/') \
- and request.method == 'GET' \
- and self.routing.match(path_info + '/'):
- new_path_info = path_info + '/'
- if request.GET:
- new_path_info = '%s?%s' % (
- new_path_info, urllib.urlencode(request.GET))
- redirect = exc.HTTPFound(location=new_path_info)
- return request.get_response(redirect)(environ, start_response)
-
- # Okay, no matches. 404 time!
- request.matchdict = {} # in case our template expects it
- return response.render_404(request)(environ, start_response)
-
- controller = common.import_component(route_match['controller'])
+ try:
+ endpoint, url_values = map_adapter.match()
+ request.matchdict = url_values
+ except NotFound as exc:
+ return render_404(request)(environ, start_response)
+ except HTTPException as exc:
+ # Support legacy webob.exc responses
+ return exc(environ, start_response)
+
+ view_func = view_functions[endpoint]
+
+ _log.debug('endpoint: {0} view_func: {1}'.format(
+ endpoint,
+ view_func))
+
+ # import the endpoint, or if it's already a callable, call that
+ if isinstance(view_func, unicode) \
+ or isinstance(view_func, str):
+ controller = common.import_component(view_func)
+ else:
+ controller = view_func
+
+ # pass the request through our meddleware classes
+ for m in self.meddleware:
+ response = m.process_request(request, controller)
+ if response is not None:
+ return response(environ, start_response)
+