summaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
authorBen Bangert <ben@groovie.org>2010-03-05 13:48:15 -0800
committerBen Bangert <ben@groovie.org>2010-03-05 13:48:15 -0800
commit6453bb827a66d349116d429335b4b9a68aacbf27 (patch)
treebb66944c318fd232c9b39d3c1954d5d9cfc47bf5 /routes
parentc559ef94b39c498c0b95e6e4bf272460c2fc6a46 (diff)
downloadroutes-6453bb827a66d349116d429335b4b9a68aacbf27.tar.gz
* Fix bug with routes not handling sub-domain defaults during generation.
--HG-- branch : trunk
Diffstat (limited to 'routes')
-rw-r--r--routes/middleware.py2
-rw-r--r--routes/util.py8
2 files changed, 8 insertions, 2 deletions
diff --git a/routes/middleware.py b/routes/middleware.py
index b772038..d4c005e 100644
--- a/routes/middleware.py
+++ b/routes/middleware.py
@@ -109,7 +109,7 @@ class RoutesMiddleware(object):
if route and route.redirect:
route_name = '_redirect_%s' % id(route)
- location = url_for(route_name, **match)
+ location = url(route_name, **match)
log.debug("Using redirect route, redirect to '%s' with status"
"code: %s", location, route.redirect_status)
start_response(route.redirect_status,
diff --git a/routes/util.py b/routes/util.py
index b2dac6d..37f292c 100644
--- a/routes/util.py
+++ b/routes/util.py
@@ -370,9 +370,15 @@ class URLGenerator(object):
if route.filter:
newargs = route.filter(newargs)
if not route.static or (route.static and not route.external):
- # Handle sub-domains
+ # Handle sub-domains, retain sub_domain if there is one
+ sub = newargs.get('sub_domain', None)
newargs = _subdomain_check(newargs, self.mapper,
self.environ)
+ # If the route requires a sub-domain, and we have it, restore
+ # it
+ if 'sub_domain' in route.defaults:
+ newargs['sub_domain'] = sub
+
elif use_current:
newargs = _screenargs(kargs, self.mapper, self.environ, force_explicit=True)
elif 'sub_domain' in kargs: