From 549f3f27dc60773ce34ce4226d3f0beb7dcef206 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Wed, 8 Aug 2012 14:20:05 -0500 Subject: [PATCH] better redirect, thanks Anthony --- VERSION | 2 +- gluon/http.py | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/VERSION b/VERSION index cdf848aa..c5ceebe0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-08-08 14:15:29) dev +Version 2.00.0 (2012-08-08 14:20:03) dev diff --git a/gluon/http.py b/gluon/http.py index 07512b54..bca52251 100644 --- a/gluon/http.py +++ b/gluon/http.py @@ -119,19 +119,16 @@ class HTTP(BaseException): return self.message -def redirect(location, how=303, type='http'): - if type=='auto': - from gluon import current - type = 'client' if current.request.ajax else 'http' - if not location: - return - location = location.replace('\r', '%0D').replace('\n', '%0A') - if type == 'client': - raise HTTP(200, **{'web2py-redirect-location': location}) - else: - raise HTTP(how, - 'You are being redirected here' % location, - Location=location) +def redirect(location, how=303, client_side=False): + if location: + from gluon import current + loc = location.replace('\r', '%0D').replace('\n', '%0A') + if client_side and current.request.ajax: + raise HTTP(200, **{'web2py-redirect-location': loc}) + else: + raise HTTP(how, + 'You are being redirected here' % loc, + Location=loc)