hot to use response during action phase?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

hot to use response during action phase?

Sebastian Sastre-2
hi there,
I need to manipulate a couple cookies from the app and when porting from 2.8 to
2.9 I've noticed the action phase has not available the response in the request
context.
I'm missing something? how are you doing such a thing with cookies in a
callback?
thanks
sebastian

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: hot to use response during action phase?

Lukas Renggli
> I need to manipulate a couple cookies from the app and when porting from 2.8 to
> 2.9 I've noticed the action phase has not available the response in the request
> context.

In Seaside 2.9 every request is processed with a request context
(instance of WARequestContext). The request context is instantiated by
the sever adaptor and knows all the necessary things to process a
request. It holds the request (instance of WARequest) and the response
(instance of WAResponse). Furthermore, it also knows the current
application and session if available.

So adding cookies is much easier in Seaside 2.9. There is no need to
do a redirect anymore, because the response that is sent back to the
browser is known upfront. Simply ask the request context for the
current response and add your cookies in the callback or render phase:

    self requestContext response addCookie: ...

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: hot to use response during action phase?

Sebastian Sastre-2
Hi Lukas, yes I've read that in the seaside site and code so I was counting with
that and I find it cool. So I made my code to be using it like that. The problem
comes because the request context returns nil when #response is sent at that
point.
In the walkback I can see this is happening during the action phase continuation
evaluation, then reach my component, it announces something other reacts and
asks:
self session response addCookie: self newLoginCookie
and then I have a nil DNU #addCookie:
there could be a problem on *when* the response inst var is initialized in the
request context? why the response is not initialized right from the begining
(request context fabrication)?
thanks
sebastian

> -----Mensaje original-----
> De: [hidden email]
> [mailto:[hidden email]] En nombre
> de Lukas Renggli
> Enviado el: Saturday, March 07, 2009 05:56
> Para: Seaside - general discussion
> Asunto: Re: [Seaside] hot to use response during action phase?
>
> > I need to manipulate a couple cookies from the app and when
> porting from 2.8 to
> > 2.9 I've noticed the action phase has not available the
> response in the request
> > context.
>
> In Seaside 2.9 every request is processed with a request context
> (instance of WARequestContext). The request context is instantiated by
> the sever adaptor and knows all the necessary things to process a
> request. It holds the request (instance of WARequest) and the response
> (instance of WAResponse). Furthermore, it also knows the current
> application and session if available.
>
> So adding cookies is much easier in Seaside 2.9. There is no need to
> do a redirect anymore, because the response that is sent back to the
> browser is known upfront. Simply ask the request context for the
> current response and add your cookies in the callback or render phase:
>
>     self requestContext response addCookie: ...
>
> Cheers,
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: hot to use response during action phase?

Julian Fitzell-2
How are you calling #response on WASession? it should be self
requestContext response addCookie:

Are you storing the request context somewhere? That would be the most
likely cause of the response being nil. You need to make sure to call
"self requestContext" at the point that you want to use to make sure
you are using the correct current context...

Julian

On Sat, Mar 7, 2009 at 4:33 PM, Sebastian Sastre <[hidden email]> wrote:

> Hi Lukas, yes I've read that in the seaside site and code so I was counting with
> that and I find it cool. So I made my code to be using it like that. The problem
> comes because the request context returns nil when #response is sent at that
> point.
> In the walkback I can see this is happening during the action phase continuation
> evaluation, then reach my component, it announces something other reacts and
> asks:
> self session response addCookie: self newLoginCookie
> and then I have a nil DNU #addCookie:
> there could be a problem on *when* the response inst var is initialized in the
> request context? why the response is not initialized right from the begining
> (request context fabrication)?
> thanks
> sebastian
>
>> -----Mensaje original-----
>> De: [hidden email]
>> [mailto:[hidden email]] En nombre
>> de Lukas Renggli
>> Enviado el: Saturday, March 07, 2009 05:56
>> Para: Seaside - general discussion
>> Asunto: Re: [Seaside] hot to use response during action phase?
>>
>> > I need to manipulate a couple cookies from the app and when
>> porting from 2.8 to
>> > 2.9 I've noticed the action phase has not available the
>> response in the request
>> > context.
>>
>> In Seaside 2.9 every request is processed with a request context
>> (instance of WARequestContext). The request context is instantiated by
>> the sever adaptor and knows all the necessary things to process a
>> request. It holds the request (instance of WARequest) and the response
>> (instance of WAResponse). Furthermore, it also knows the current
>> application and session if available.
>>
>> So adding cookies is much easier in Seaside 2.9. There is no need to
>> do a redirect anymore, because the response that is sent back to the
>> browser is known upfront. Simply ask the request context for the
>> current response and add your cookies in the callback or render phase:
>>
>>     self requestContext response addCookie: ...
>>
>> Cheers,
>> Lukas
>>
>> --
>> Lukas Renggli
>> http://www.lukas-renggli.ch
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside