summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bangert <ben@groovie.org>2010-06-05 09:59:48 -0700
committerBen Bangert <ben@groovie.org>2010-06-05 09:59:48 -0700
commite16850351443b4294383aa91cd22a32aab7f081a (patch)
tree76d5776d1f2af164c511efc951f8e148911d31ac
parent086414263069a5d268835a9f2becf7fe6d78ef62 (diff)
downloadroutes-e16850351443b4294383aa91cd22a32aab7f081a.tar.gz
* Fix bug with URLGenerator not properly including SCRIPT_NAME when generating
URL's and the singleton is not present. --HG-- branch : trunk
-rw-r--r--CHANGELOG9
-rw-r--r--routes/mapper.py7
-rw-r--r--routes/util.py1
-rw-r--r--setup.py2
-rw-r--r--tests/test_functional/test_explicit_use.py14
-rw-r--r--tests/test_functional/test_utils.py2
6 files changed, 31 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 8b441a7..6a207dc 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,15 @@
Routes Changelog
%%%%%%%%%%%%%%%%
+Release 1.12.3 (**tip**)
+* Fix bug with URLGenerator not properly including SCRIPT_NAME when generating
+ URL's and the singleton is not present.
+
+Release 1.12.2 (May 5, 2010)
+============================
+* Fix bug with routes URLGenerator not properly including SCRIPT_NAME when
+ generating qualified URL's.
+
Release 1.12.1 (March 11, 2010)
===============================
* Fix bug with routes not generating URL's with callables in defaults.
diff --git a/routes/mapper.py b/routes/mapper.py
index 50f7482..18ade09 100644
--- a/routes/mapper.py
+++ b/routes/mapper.py
@@ -717,6 +717,7 @@ class Mapper(SubMapperParent):
if 'action' not in kargs:
kargs['action'] = 'index'
+ environ = kargs.pop('_environ', self.environ)
controller = kargs.get('controller', None)
action = kargs.get('action', None)
@@ -729,7 +730,7 @@ class Mapper(SubMapperParent):
if self.urlcache is not None:
if self.environ:
cache_key_script_name = '%s:%s' % (
- self.environ.get('SCRIPT_NAME', ''), cache_key)
+ environ.get('SCRIPT_NAME', ''), cache_key)
else:
cache_key_script_name = cache_key
@@ -824,9 +825,9 @@ class Mapper(SubMapperParent):
if self.prefix:
path = self.prefix + path
external_static = route.static and route.external
- if self.environ and self.environ.get('SCRIPT_NAME', '') != ''\
+ if environ and environ.get('SCRIPT_NAME', '') != ''\
and not route.absolute and not external_static:
- path = self.environ['SCRIPT_NAME'] + path
+ path = environ['SCRIPT_NAME'] + path
key = cache_key_script_name
else:
key = cache_key
diff --git a/routes/util.py b/routes/util.py
index 6c3f845..d0d9672 100644
--- a/routes/util.py
+++ b/routes/util.py
@@ -389,6 +389,7 @@ class URLGenerator(object):
anchor = anchor or newargs.pop('_anchor', None)
host = host or newargs.pop('_host', None)
protocol = protocol or newargs.pop('_protocol', None)
+ newargs['_environ'] = self.environ
url = self.mapper.generate(*route_args, **newargs)
if anchor is not None:
url += '#' + _url_quote(anchor, encoding)
diff --git a/setup.py b/setup.py
index 58faaec..e10d0be 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ except ImportError:
use_setuptools()
from setuptools import setup, find_packages
-version = '1.12.1'
+version = '1.12.2'
setup(name="Routes",
version=version,
diff --git a/tests/test_functional/test_explicit_use.py b/tests/test_functional/test_explicit_use.py
index f40e0f4..3f667c4 100644
--- a/tests/test_functional/test_explicit_use.py
+++ b/tests/test_functional/test_explicit_use.py
@@ -105,3 +105,17 @@ class TestUtils(unittest.TestCase):
environ['wsgiorg.routing_args'] = (None, match)
url = URLGenerator(m, environ)
eq_('/hi/smith', url.current())
+
+ def test_using_prefix(self):
+ m = Mapper()
+ m.explicit = True
+ m.connect('/{first}/{last}')
+
+ environ = {'HTTP_HOST': 'localhost.com', 'PATH_INFO': '/content/index', 'SCRIPT_NAME': '/jones'}
+ match = m.routematch(environ=environ)[0]
+ environ['wsgiorg.routing_args'] = (None, match)
+ url = URLGenerator(m, environ)
+
+ eq_('/jones/content/index', url.current())
+ eq_('/jones/smith/barney', url(first='smith', last='barney'))
+
diff --git a/tests/test_functional/test_utils.py b/tests/test_functional/test_utils.py
index 9cdbc80..808ca1e 100644
--- a/tests/test_functional/test_utils.py
+++ b/tests/test_functional/test_utils.py
@@ -291,6 +291,7 @@ class TestUtils(unittest.TestCase):
m.connect(':controller/:action/:id')
m.connect('home', 'http://www.groovie.org/', _static=True)
m.connect('space', '/nasa/images', _static=True)
+ m.connect('login', '/login', action='nowhereville')
m.create_regs(['content', 'blog'])
self.con.environ.update({'wsgiorg.routing_args':((), {})})
@@ -301,6 +302,7 @@ class TestUtils(unittest.TestCase):
eq_('/webapp/content/view', urlobj(controller='content', action='view'))
eq_('/webapp/nasa/images?search=all', urlobj('space', search='all'))
eq_('http://example.com/webapp/nasa/images', urlobj('space', protocol='http'))
+ eq_('http://example.com/webapp/login', urlobj('login', qualified=True))
def test_static_route_with_vars(self):
m = self.con.mapper