I want to manage external links in a central place in my app so that if they change I need only change them in one place.
Since I'm already using webapp2s routing, I figured I could use that, and use url_for just like every other link. So, tried the following:
Route('http://www.google.com', name='google', build_only=True)
but when I render the link, like this:
uri_for('google')
It encodes the http:// bit, like this:
http%3A//www.google.com
which means if you use it in a href tag, you end up with a relative link like this:
http://localhost:8080/some/path/http%3A//www.google.com
So, questions are:
Would be nice to use webapp2s routing so I can seamlessly use url_for without having to write another 'same but different' method.
I managed to solve the issue by implementing my own uri_for method, and using that instead
def uri_for(_name, _request=None, *args, **kwargs):
uri = webapp2.uri_for(_name, _request, *args, **kwargs)
return urllib.unquote(uri)