summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2009-09-30 06:30:15 +0000
committerChris McDonough <chrism@agendaless.com>2009-09-30 06:30:15 +0000
commitb38e3243cc6d1551483c33a23bd5d3c3f5f38915 (patch)
tree7668d02240207e77b2008d77ffa06b90be4b56e2
parentb17af4f512232ae057e5d4ea3221aedac0524a86 (diff)
downloadpyramid-b38e3243cc6d1551483c33a23bd5d3c3f5f38915.tar.gz
pyramid-b38e3243cc6d1551483c33a23bd5d3c3f5f38915.tar.bz2
pyramid-b38e3243cc6d1551483c33a23bd5d3c3f5f38915.zip
Don't do lookup if we're going to fail.
-rw-r--r--repoze/bfg/url.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/repoze/bfg/url.py b/repoze/bfg/url.py
index 40badf5d1..c7b98adfc 100644
--- a/repoze/bfg/url.py
+++ b/repoze/bfg/url.py
@@ -228,8 +228,6 @@ def static_url(path, request, **kw):
.. note:: This feature is new in :mod:`repoze.bfg` 1.1.
"""
- mapper = getUtility(IRoutesMapper)
- routes = mapper.get_routes()
if os.path.isabs(path):
raise ValueError('Absolute paths cannot be used to generate static '
'urls (use a package-relative path or a resource '
@@ -241,6 +239,9 @@ def static_url(path, request, **kw):
package = caller_package(level=2)
path = '%s:%s' % (package.__name__, path)
+ mapper = getUtility(IRoutesMapper)
+ routes = mapper.get_routes()
+
for route in routes:
factory = route.factory
if factory.__class__ is StaticRootFactory: