diff --git a/VERSION b/VERSION index 212f6ead..ace936de 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-08-08 09:43:04) dev +Version 2.00.0 (2012-08-08 10:05:06) dev diff --git a/applications/admin/static/js/web2py.js b/applications/admin/static/js/web2py.js index 20f67b3a..9a2e208c 100644 --- a/applications/admin/static/js/web2py.js +++ b/applications/admin/static/js/web2py.js @@ -44,6 +44,12 @@ function web2py_event_handlers() { doc.on('keyup', 'input.double, input.decimal', function(){this.value=this.value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').reverse();}); var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') ? w2p_ajax_confirm_message : "Are you sure you want to delete this object?"; doc.on('click', "input[type='checkbox'].delete", function(){if(this.checked) if(!confirm(confirm_message)) this.checked=false;}); + doc.ajaxSuccess(function(e, xhr) { + var redirect=xhr.getResponseHeader('web2py-redirect-location'); + if (redirect != null) { + window.location = redirect; + }; + }); }; jQuery(function() { diff --git a/applications/examples/static/js/web2py.js b/applications/examples/static/js/web2py.js index 20f67b3a..9a2e208c 100644 --- a/applications/examples/static/js/web2py.js +++ b/applications/examples/static/js/web2py.js @@ -44,6 +44,12 @@ function web2py_event_handlers() { doc.on('keyup', 'input.double, input.decimal', function(){this.value=this.value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').reverse();}); var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') ? w2p_ajax_confirm_message : "Are you sure you want to delete this object?"; doc.on('click', "input[type='checkbox'].delete", function(){if(this.checked) if(!confirm(confirm_message)) this.checked=false;}); + doc.ajaxSuccess(function(e, xhr) { + var redirect=xhr.getResponseHeader('web2py-redirect-location'); + if (redirect != null) { + window.location = redirect; + }; + }); }; jQuery(function() { diff --git a/applications/welcome/static/js/web2py.js b/applications/welcome/static/js/web2py.js index 20f67b3a..9a2e208c 100644 --- a/applications/welcome/static/js/web2py.js +++ b/applications/welcome/static/js/web2py.js @@ -44,6 +44,12 @@ function web2py_event_handlers() { doc.on('keyup', 'input.double, input.decimal', function(){this.value=this.value.reverse().replace(/[^0-9\-\.,]|[\-](?=.)|[\.,](?=[0-9]*[\.,])/g,'').reverse();}); var confirm_message = (typeof w2p_ajax_confirm_message != 'undefined') ? w2p_ajax_confirm_message : "Are you sure you want to delete this object?"; doc.on('click', "input[type='checkbox'].delete", function(){if(this.checked) if(!confirm(confirm_message)) this.checked=false;}); + doc.ajaxSuccess(function(e, xhr) { + var redirect=xhr.getResponseHeader('web2py-redirect-location'); + if (redirect != null) { + window.location = redirect; + }; + }); }; jQuery(function() { diff --git a/gluon/http.py b/gluon/http.py index 17945b68..df175175 100644 --- a/gluon/http.py +++ b/gluon/http.py @@ -119,13 +119,18 @@ class HTTP(BaseException): return self.message -def redirect(location, how=303): +def redirect(location, how=303, type=None): + from gluon import current + type = type or ('client' if current.request.ajax else 'http') if not location: return location = location.replace('\r', '%0D').replace('\n', '%0A') - raise HTTP(how, - 'You are being redirected here' % location, - Location=location) + if type == 'client': + raise HTTP(200, **{'web2py-redirect-location': location}) + else: + raise HTTP(how, + 'You are being redirected here' % location, + Location=location)