Thanks, Anthony. I really appreciate your thorough responses. You don't 
just say how to do something, you explain why it works the way it works. 
That kind of response is rare and invaluable. It keeps me from asking the 
same question different ways because I end up understanding how the system 
works under the hood. Please keep up the good work. I would tell your boss 
to give you a raise, but I wouldn't want to get you fired for putting so 
much time into the web2py group! (How ironic, eh?)

On Tuesday, March 27, 2012 10:49:45 PM UTC+8, Anthony wrote:
>
> 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