[Catalyst] Scheduler Plugin localizing
Bill Moseley
moseley at hank.org
Wed May 3 05:24:24 CEST 2006
The scheduler plugin does this before calling the scheduled task:
# do not allow the event to modify the response
local $c->res->{body};
local $c->res->{cookies};
local $c->res->{headers};
local $c->res->{location};
local $c->res->{status};
Which sets those to undef. So if the cron task does something in
catalyst things blow up.
[Tue May 2 19:30:02 2006] [catalyst] [error] Scheduler: Error executing remind: Caught exception in WS2::C::Cron->reminders "Can't call method "content_type" on an undefined value at /home/moseley/local/share/perl/5.8.4/Catalyst/Response.pm line 12."
I'm currently using:
local $c->res->{$_} = $c->res->{$_}
for qw/ body cookies headers location status/;
But that doesn't really protect headers and cookies.
Is there a better way to protect the catalyst environment from the
scheduled task changing things?
Assuming there's not reason a cron task would want to alter the
current request, Would this work for headers?
my $headers = $c->res->{headers};
$c->res->{headers} = $headers->clone;
[ call scheduled task ]
$c->res->{headers} = $headers;
What about cookies?
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list