From 9336d44d79232b021cc5f871aa43a384958e1920 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 12 Jul 2010 13:37:51 +0000 Subject: - Fix regression in ``repoze.bfg.configuration.Configurator.add_static_view``. Before 1.3a4, view names that contained a slash were supported as route prefixes. 1.3a4 broke this by trying to treat them as full URLs. --- repoze/bfg/static.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'repoze/bfg/static.py') diff --git a/repoze/bfg/static.py b/repoze/bfg/static.py index f2dfa7897..36a855dfb 100644 --- a/repoze/bfg/static.py +++ b/repoze/bfg/static.py @@ -1,6 +1,7 @@ import os import pkg_resources from urlparse import urljoin +from urlparse import urlparse from paste import httpexceptions from paste import request @@ -94,10 +95,10 @@ class StaticURLInfo(object): self.registrations = [] def generate(self, path, request, **kw): - for (name, spec) in self.registrations: + for (name, spec, is_url) in self.registrations: if path.startswith(spec): subpath = path[len(spec):] - if '/' in name: + if is_url: return urljoin(name, subpath[1:]) else: kw['subpath'] = subpath @@ -111,11 +112,12 @@ class StaticURLInfo(object): idx = names.index(name) self.registrations.pop(idx) - if '/' in name: + if urlparse(name)[0]: # it's a URL if not name.endswith('/'): # make sure it ends with a slash name = name + '/' + self.registrations.append((name, spec, True)) else: # it's a view name _info = extra.pop('_info', None) @@ -130,8 +132,7 @@ class StaticURLInfo(object): factory=lambda *x: self, _info=_info ) - - self.registrations.append((name, spec)) + self.registrations.append((name, spec, False)) class static_view(object): """ An instance of this class is a callable which can act as a -- cgit v1.2.3