[Catalyst] RunAfterRequest/delayed Catalyst view
Steve Kleiman
steve at prodhub.com
Fri Apr 30 21:38:50 GMT 2010
Here goes...hopefully a simple test case for the RunAfterRequest oddness.
The code below works as expected...an email is dispatched.
==============
sub tester :Local {
my ( $self, $c ) = @_;
$c->stash(
email => {
to => 'steve at prodhub.com',
from => 'bockscar at mac.com',
subject => 'RunAfterRequest Test',
templates => [
{
template => 'test.tt2',
content_type => 'text/plain',
view => 'TT',
},
],
},
);
$c->forward( $c->view('Email::Template') );
$c->response->body('foo bar');
}
==============
The code below with the forward INSIDE 'run_after_request' subroutine throws the error:
> [error] Caught exception in engine "Modification of non-creatable array value attempted, subscript -1 at /usr/local/lib/perl5/site_perl/5.10.1/Catalyst/Dispatcher.pm line 278."
Doesn't matter whether the stash call is inside or outside the subroutine.
==============
sub tester :Local {
my ( $self, $c ) = @_;
$c->stash(
email => {
to => 'steve at prodhub.com',
from => 'bockscar at mac.com',
subject => 'RunAfterRequest Test',
templates => [
{
template => 'test.tt2',
content_type => 'text/plain',
view => 'TT',
},
],
},
);
$c->run_after_request( sub {
$c->forward( $c->view('Email::Template') );
});
$c->response->body('foo bar');
}
==============
The Catalyst::Dispatcher code where the error occurs is the $c->stack line below:
==============
sub _action_rel2abs {
my ( $self, $c, $path ) = @_;
unless ( $path =~ m#^/# ) {
my $namespace = $c->stack->[-1]->namespace;
$path = "$namespace/$path";
}
$path =~ s#^/##;
return $path;
}
==============
[END]
On Apr 29, 2010, at 11:18 PM, Devin Austin wrote:
>
>
> On Fri, Apr 30, 2010 at 12:09 AM, Tomas Doran <bobtfish at bobtfish.net> wrote:
>
> On 30 Apr 2010, at 07:00, Steve Kleiman wrote:
> Thanks in advance for any insights.
>
> No ideas I'm afraid.
>
> However I don't see any reason why this couldn't / shouldn't work..
>
> Could you work up some test cases (or a very small test app) for either View::Email or ::RunAfterRequest which demonstrates the issue?
>
> Cheers
> t0m
>
>
> _______________________________________________
> 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/
>
> Yes, patches welcome, I'd like to see how this would work.
>
> --
> Devin Austin
> http://www.codedright.net
> 9702906669 - Cell
> _______________________________________________
> 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/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100430/d554d383/attachment.htm
More information about the Catalyst
mailing list