summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bangert <ben@groovie.org>2010-03-11 09:18:53 -0800
committerBen Bangert <ben@groovie.org>2010-03-11 09:18:53 -0800
commit87906e9212bcbb27719d37d6b520e2a66c0472c1 (patch)
tree923832c812cb7676db9baf2ff1ccc8ba6d86e55b
parent6453bb827a66d349116d429335b4b9a68aacbf27 (diff)
downloadroutes-87906e9212bcbb27719d37d6b520e2a66c0472c1.tar.gz
* Fix bug with routes not generating URL's with callables in defaults.v1.12.1
--HG-- branch : trunk
-rw-r--r--CHANGELOG1
-rw-r--r--routes/mapper.py4
-rw-r--r--routes/util.py1
-rw-r--r--tests/test_functional/test_explicit_use.py13
4 files changed, 17 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ef4cdb8..ad6e737 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@ Routes Changelog
Release 1.13 (**tip**)
======================
+* Fix bug with routes not generating URL's with callables in defaults.
* Fix bug with routes not handling sub-domain defaults during generation.
Release 1.12 (February 28, 2010)
diff --git a/routes/mapper.py b/routes/mapper.py
index 79a2007..50f7482 100644
--- a/routes/mapper.py
+++ b/routes/mapper.py
@@ -814,7 +814,7 @@ class Mapper(SubMapperParent):
kval = kval.decode(self.encoding)
else:
kval = unicode(kval)
- if kval != route.defaults[key]:
+ if kval != route.defaults[key] and not callable(route.defaults[key]):
fail = True
break
if fail:
@@ -1144,7 +1144,7 @@ class Mapper(SubMapperParent):
# Create the dict of args for the generation route
for key in both_args + gen_args:
if key in kwargs:
- gen_dict = kwargs[key]
+ gen_dict[key] = kwargs[key]
gen_dict['_static'] = True
# Create the dict of args for the matching route
diff --git a/routes/util.py b/routes/util.py
index 37f292c..6c3f845 100644
--- a/routes/util.py
+++ b/routes/util.py
@@ -385,6 +385,7 @@ class URLGenerator(object):
newargs = _subdomain_check(kargs, self.mapper, self.environ)
else:
newargs = kargs
+
anchor = anchor or newargs.pop('_anchor', None)
host = host or newargs.pop('_host', None)
protocol = protocol or newargs.pop('_protocol', None)
diff --git a/tests/test_functional/test_explicit_use.py b/tests/test_functional/test_explicit_use.py
index 4cf1244..f40e0f4 100644
--- a/tests/test_functional/test_explicit_use.py
+++ b/tests/test_functional/test_explicit_use.py
@@ -92,3 +92,16 @@ class TestUtils(unittest.TestCase):
]
map.extend(routes)
eq_(map.match('/foo'), {})
+
+ def test_using_func(self):
+ def fred(view): pass
+
+ m = Mapper()
+ m.explicit = True
+ m.connect('/hi/{fred}', controller=fred)
+
+ environ = {'HTTP_HOST': 'localhost.com', 'PATH_INFO': '/hi/smith'}
+ match = m.routematch(environ=environ)[0]
+ environ['wsgiorg.routing_args'] = (None, match)
+ url = URLGenerator(m, environ)
+ eq_('/hi/smith', url.current())