Commits

Andriy Kornatskyy committed 1eaa979

Fixed issue #5: The use of defaultattrdict in routing middleware may lead to unexpected path construction.

Comments (0)

Files changed (2)

src/wheezy/web/middleware/errors.py

         status_code = response.status_code
         if status_code >= 400:
             error_route_name = self.error_mapping[status_code]
-            route_name = request.environ['route_args']['route_name']
+            route_name = request.environ['route_args'].get('route_name')
             if error_route_name != route_name:
                 response = RedirectRouteHandler(request, error_route_name)
         return response

src/wheezy/web/middleware/routing.py

 """ ``routing`` module.
 """
 
-from wheezy.core.collections import defaultattrdict
+from wheezy.core.collections import attrdict
 
 
 class PathRoutingMiddleware(object):
     def __call__(self, request, following):
         environ = request.environ
         handler, route_args = self.match(environ['PATH_INFO'].lstrip('/'))
-        environ['route_args'] = defaultattrdict(str, route_args)
+        environ['route_args'] = attrdict(route_args)
         if handler is None:
             if following is not None:
                 return following(request)