[Catalyst] Force the session to be saved.

Kieren Diment diment at gmail.com
Wed Mar 30 08:50:53 GMT 2011


You can mess with the metaclass to do what you want, but I don't know how to do it myself I'm afraid.

On 30/03/2011, at 7:40 PM, Duncan Garland wrote:

> Thanks. That's very useful and a bit depressing.
> 
> -----Original Message-----
> From: Andrew Rodland [mailto:andrew at cleverdomain.org] 
> Sent: 29 March 2011 19:33
> To: The elegant MVC web framework
> Subject: Re: [Catalyst] Force the session to be saved.
> 
> On Tuesday, March 29, 2011 12:46:32 PM Duncan Garland wrote:
>> Hi,
>> 
>> We've been having some peculiar behaviour from our system. I think it's
>> because the controller which produces the HTML page stores data in the
>> session for retrieval by the controller which produces the associated
>> javascript file.
>> 
>> The client begins processing the HTML page as soon as it starts to arrive.
>> When it reaches the script tag it requests the javascript page.
>> Occasionally the first controller hasn't written the session to the
>> database when the javascript controller tries to retrieve it.
>> (Catalyst::Plugin::Session::Store::DBIC).
>> 
>> I can move the script tag down the page a bit, but what I really need is a
>> way to force the session to be written before the HTML template is
>> rendered.
>> 
>> Something like:
>> 
>> $c->session->{javascript}->{$template}  = { one = 1, two => 2};
>> $c->session->save;
>> 
>> Is there such a method?
>> 
>> Regards
>> 
>> Duncan
> 
> finalize_session (which writes the session to the DB) runs before 
> finalize_body (which writes the response to the client), so Catalyst already 
> does what you would like it to, and forcing a session write before running the 
> view is unlikely to help anything. I suspect either your database isn't 
> guaranteeing ordering, or the problem is somewhere other than where you're 
> looking.
> 
> Andrew
> 
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
> 
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/




More information about the Catalyst mailing list