comparison MoinMoin/web/contexts.py @ 5659:80a7f3cd237b

deal with werkzeug 0.6.x behaviour change if redirect() gets unicode 0.5.x seems to happily accept both unicode and str and do same for both. 0.6.x does iri-to-uri transform if it gets unicode (including url-quoting). As our "unicode url" is already url-quoted, we just use str() to make it a str before giving it to werkzeug, so it behaves in the same way for werkzeug 0.5.x and 0.6.x.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 28 Apr 2010 12:29:55 +0200
parents 1dff6cfdcf90
children 8ed0f132fb44
comparison
equal deleted inserted replaced
5658:24d7e2f450bf 5659:80a7f3cd237b
267 self.headers['Pragma'] = 'no-cache' 267 self.headers['Pragma'] = 'no-cache'
268 self.request.expires = time.time() - 3600 * 24 * 365 268 self.request.expires = time.time() - 3600 * 24 * 365
269 269
270 def http_redirect(self, url, code=302): 270 def http_redirect(self, url, code=302):
271 """ Raise a simple redirect exception. """ 271 """ Raise a simple redirect exception. """
272 # werkzeug >= 0.6 does iri-to-uri transform if it gets unicode, but our
273 # url is already url-quoted, so we better give it str to have same behaviour
274 # with werkzeug 0.5.x and 0.6.x:
275 url = str(url) # if url is unicode, it should contain ascii chars only
272 abort(redirect(url, code=code)) 276 abort(redirect(url, code=code))
273 277
274 def http_user_agent(self): 278 def http_user_agent(self):
275 return self.environ.get('HTTP_USER_AGENT', '') 279 return self.environ.get('HTTP_USER_AGENT', '')
276 http_user_agent = EnvironProxy(http_user_agent) 280 http_user_agent = EnvironProxy(http_user_agent)