[Seaside-dev] RE: [Seaside] hot to use response during action phase?

Julian Fitzell jfitzell at gmail.com
Thu Mar 12 09:10:13 UTC 2009


Yes, in 2.9a2 it will be nil. In 2.9a2 (and 2.8 I think) that variable
is assigned in some weird cases but it's only intended to be read by
the Server Adaptor. It is not always set. You are expected to return a
response (you can just create a new Response and return it).

The current development code will always provide a Response in the
RequestContext and you are required to use that one. As a result, you
no longer are expected to return a Response; you must modify the one
that's there. This facilitates streaming and allows adding cookies
during the action phase.

Julian

On Wed, Mar 11, 2009 at 10:34 PM, Sebastian Sastre <ssastre at seaswork.com> wrote:
> for the record:
> I've tried again in a fresh loaded and updated pharo and s2.9a2 but still seeing
> nil in the response in an action callback.
> sebastian
>
>
>> -----Mensaje original-----
>> De: seaside-dev-bounces at lists.squeakfoundation.org
>> [mailto:seaside-dev-bounces at lists.squeakfoundation.org] En
>> nombre de Julian Fitzell
>> Enviado el: Monday, March 09, 2009 11:06
>> Para: Seaside - developer list
>> Asunto: Re: [Seaside-dev] RE: [Seaside] hot to use response
>> during action phase?
>>
>> Hm... I don't hit that halt so I don't seem to be able to reproduce. I
>> far as I can tell by looking, your code looks fine. In fact, if I
>> change your #addCookie method as follows then I actually get a cookie
>> added:
>>
>> addCookie
>>       "If response is nil here, I can't cookie :('"
>>       self requestContext response addCookie:
>>               (self requestContext newCookie
>>                       key: 'foo';
>>                       value: 'bar';
>>                       yourself)
>>
>> How old is the Seaside code you are using?
>>
>> (by the way, you can just call "self requestContext"; you don't need
>> "self session requestContext")
>>
>> Julian
>>
>> On Mon, Mar 9, 2009 at 1:41 PM, Sebastian Sastre
>> <ssastre at seaswork.com> wrote:
>> > Hi Julian, I'm sending you a demo with the problem
>> > best,
>> > sebastian
>> >
>> >> -----Mensaje original-----
>> >> De: seaside-dev-bounces at lists.squeakfoundation.org
>> >> [mailto:seaside-dev-bounces at lists.squeakfoundation.org] En
>> >> nombre de Julian Fitzell
>> >> Enviado el: Sunday, March 08, 2009 06:23
>> >> Para: Seaside - developer list
>> >> Asunto: Re: [Seaside-dev] RE: [Seaside] hot to use response
>> >> during action phase?
>> >>
>> >> Can you show the code that is calling this method?
>> >>
>> >> On Sat, Mar 7, 2009 at 5:18 PM, Sebastian Sastre
>> >> <ssastre at seaswork.com> wrote:
>> >> > hi Julian,
>> >> > you're right, dev is better for this.
>> >> > Look, in a WASession subclass I have this piece of code:
>> >> >
>> >> >  self requestContext response
>> >> >                        addCookie: (WACookie new
>> >> >                                                key: self
>> >> loginRememberKey;
>> >> >                                                value:
>> >> loginCookieValue;
>> >> >                                                yourself)
>> >> >
>> >> > and I can see the request context is called from the
>> >> process variable and it is
>> >> > not nil but its response instVar is nil and I found that's
>> >> inconvenient
>> >> > cheers,
>> >> > seaside
>> >> >
>> >> >
>> >> >> -----Mensaje original-----
>> >> >> De: seaside-bounces at lists.squeakfoundation.org
>> >> >> [mailto:seaside-bounces at lists.squeakfoundation.org] En nombre
>> >> >> de Julian Fitzell
>> >> >> Enviado el: Saturday, March 07, 2009 12:51
>> >> >> Para: Seaside - general discussion
>> >> >> Asunto: Re: [Seaside] hot to use response during action phase?
>> >> >>
>> >> >> 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
>> >> >> <ssastre at seaswork.com> 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: seaside-bounces at lists.squeakfoundation.org
>> >> >> >> [mailto:seaside-bounces at lists.squeakfoundation.org] 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
>> >> >> >> seaside at lists.squeakfoundation.org
>> >> >> >>
>> >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >> >> >
>> >> >> > _______________________________________________
>> >> >> > seaside mailing list
>> >> >> > seaside at lists.squeakfoundation.org
>> >> >> >
>> >> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >> >> >
>> >> >> _______________________________________________
>> >> >> seaside mailing list
>> >> >> seaside at lists.squeakfoundation.org
>> >> >>
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >> >
>> >> > _______________________________________________
>> >> > seaside-dev mailing list
>> >> > seaside-dev at lists.squeakfoundation.org
>> >> > http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>> >> >
>> >> _______________________________________________
>> >> seaside-dev mailing list
>> >> seaside-dev at lists.squeakfoundation.org
>> >> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>> >
>> > _______________________________________________
>> > seaside-dev mailing list
>> > seaside-dev at lists.squeakfoundation.org
>> > http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>> >
>> >
>> _______________________________________________
>> seaside-dev mailing list
>> seaside-dev at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>
> _______________________________________________
> seaside-dev mailing list
> seaside-dev at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>


More information about the seaside-dev mailing list