[Nitro] Seaside style call/answer mechanism

Michael Neumann mneumann at ntecs.de
Thu Nov 24 13:11:35 EST 2005


Am 24.11.2005 um 18:49 schrieb George Moschovitis:

> Dear devs,
>
> I would like to add a Seaside-inspired feature to Nitro. A call/answer
> mechanism. I 'll try to explain with an example. Let's say you want to
> make some pages only accessible to logged in users:
>
> class MyController
>
>   def my_page
>      @user ||= call(:login)
>      ...
>   end
>
>   ...
>
>    def login
>      ...
>      answer user
>    end
> end
>
> when returning from the login page nitro should redirect to the
> caller. Anyone has any ideas how to implement this. I don't want the
> full power of Seaside call/answer. But I am not sure how to handle the
> case when a user has multiple windows open at the same time.

One possible implementation:

Upon call, push the current URL on a stack. Answer then simply  
returns to the
top of stack element. Of course this doesn't work well if you, after  
you've had called a controller, type in an URL by hand. Another idea  
is to introduce a special "stack" ID (e.g. ?stid=xxx) upon #call, and  
store a stack under this ID in the session. #answer only works if a  
stid is specified.

In Seaside/Wee the whole thing is implemented not by storing URLs,  
but actually the state of the component as of the time when you call  
#call.

Regards,

   Michael




More information about the Nitro-general mailing list