From e16850351443b4294383aa91cd22a32aab7f081a Mon Sep 17 00:00:00 2001 From: Ben Bangert Date: Sat, 5 Jun 2010 09:59:48 -0700 Subject: * Fix bug with URLGenerator not properly including SCRIPT_NAME when generating URL's and the singleton is not present. --HG-- branch : trunk --- routes/mapper.py | 7 ++++--- routes/util.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'routes') 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) -- cgit v1.2.1