>
> I want something like this to work, but it doesn't, obviously. 
>
> def logout(): 
>     auth.logout() 
>     response.js = 'alert("goodbye world");' 
>     from gluon import HTTP 
>     HTTP(202) 
>     return dict() 
>
> I've also tried auth.settings.logout_onlogout = [onlogoutfunction] 
> but that's not working for me either.


auth.logout() does a redirect, so the above won't make it to your HTTP(202) 
call. Also, response.js only works for Ajax requests for components (i.e., 
client-side calls to web2py_ajax_page(), which is what the LOAD helper 
does).

How is the logout request made from the browser? If it is a regular full 
page request, your controller needs to return a full page (probably via the 
typical post-logout redirect), and that page then needs to include the 
relevant JS code (e.g., in a <script> element). If the logout request is 
made via Ajax, you might use the web2py ajax() function with ":eval" as the 
third argument, and then simply return the JS you want to execute (":eval" 
tells the ajax() function to execute the returned value as JS rather than 
put it into a target element in the DOM).

Anthony 

Reply via email to