better redirect, thanks Anthony
This commit is contained in:
1 parent
b1a9df7d67
commit
4c41057ffb
2 files changed
+8
-11
No files matched your search
@@ -1 +1 @@
|
|||||||
Version 2.00.0 (2012-08-08 14:15:29) dev
|
Version 2.00.0 (2012-08-08 14:20:03) dev
|
||||||
+7
-10
@@ -119,19 +119,16 @@ class HTTP(BaseException):
|
|||||||
return self.message
|
return self.message
|
||||||
|
|
||||||
|
|
||||||
def redirect(location, how=303, type='http'):
|
def redirect(location, how=303, client_side=False):
|
||||||
if type=='auto':
|
if location:
|
||||||
from gluon import current
|
from gluon import current
|
||||||
type = 'client' if current.request.ajax else 'http'
|
loc = location.replace('\r', '%0D').replace('\n', '%0A')
|
||||||
if not location:
|
if client_side and current.request.ajax:
|
||||||
return
|
raise HTTP(200, **{'web2py-redirect-location': loc})
|
||||||
location = location.replace('\r', '%0D').replace('\n', '%0A')
|
|
||||||
if type == 'client':
|
|
||||||
raise HTTP(200, **{'web2py-redirect-location': location})
|
|
||||||
else:
|
else:
|
||||||
raise HTTP(how,
|
raise HTTP(how,
|
||||||
'You are being redirected <a href="%s">here</a>' % location,
|
'You are being redirected <a href="%s">here</a>' % loc,
|
||||||
Location=location)
|
Location=loc)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user