This is maybe better done with [pyramid.url.urlencode()](http://docs.pylonsproject.org/projects/pyramid/en/1.0-branch/api/url.html#pyramid.url.urlencode)