[Catalyst] Catalyst::Plugin::RunAfterRequest and Catalyst::View::Email?

Steve Kleiman steve at prodhub.com
Wed Mar 2 21:33:48 GMT 2011


See mst note below. Worked for me.


On Mar 2, 2011, at 12:12 PM, Chakkit Ngamsom wrote:

> Hi All,
>  =

> My plan is to use Catalyst::Plugin::RunAfterRequest for sending email via=
 Catalyst::View::Email as the background.
> Due to sometimes mail server got lag and the page waiting for it or sendi=
ng a notification after slow processes have been completed e.g. import/expo=
rt.
>  =

> I=92m not sure it=92s a bug or the limitation of the plugin.
> I setup the code something like this:
>  =

> $c->run_after_request(
>   sub {
>     $c->stash->{email} =3D {
>       from =3D> $from,
>       to =3D> $to,
>       body =3D> $body,
>       header =3D> [
>         Subject =3D> 'some localized subject',
>       ],
>     };
>     $c->forward( $c->view('Email') );
>   }
> );
>  =

> After running it, it showed an error like this:
> [error] Caught exception in engine "Modification of non-creatable array v=
alue attempted, subscript -1 at C:/strawberry/perl/site/lib/Catalyst/Dispat=
cher.pm line 278."
>  =

> As a trial, the error caused from this line: $c->forward( $c->view('Email=
') );.
> Finally, I noticed it worked well with other forwarding except view.
>  =

> Please kindly let me know how to fix this issue or another solution that =
matches to the requirements.
>  =

> Thanks in advance,
> Chakkit
> =







Begin forwarded message:

> From: Matt S Trout <mst at shadowcat.co.uk>
> Date: May 2, 2010 12:49:32 PM PDT
> To: The elegant MVC web framework <catalyst at lists.scsys.co.uk>
> Subject: Re: [Catalyst] RunAfterRequest/delayed Catalyst view
> Reply-To: The elegant MVC web framework <catalyst at lists.scsys.co.uk>
> =

> On Fri, Apr 30, 2010 at 02:38:50PM -0700, Steve Kleiman wrote:
>> Here goes...hopefully a simple test case for the RunAfterRequest oddness.
> =

>> The code below with the forward INSIDE 'run_after_request' subroutine th=
rows 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/Cat=
alyst/Dispatcher.pm line 278."
> =

> I think that's probably $c->stack being empty because there's no request
> anymore.
> =

> I *think* that
> =

> $c->view('Email')->process($c);
> =

> would work, since that doesn't rely on the action call stack.
> =

> That error message is fucking awful though, and almost certainly my fault.
> =

> Proposal: first you try the ->process-by-hand approach to confirm that I'm
> an idiot the way I think I am. Second we discuss how to either (a) fix th=
is
> or (b) make sure it produces a non-awful error.
> =

> (even if you've already rewritten the code it'd be much appreciated if you
> could try this out and see if it does the right thing - also, you then ge=
t to
> point and laugh at me with a bit of luck, which may or may not be an added
> incentive ;)
> =

> -- =

> Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and =
a clue
> =

> http://shadowcat.co.uk/blog/matt-s-trout/   http://twitter.com/shadowcat_=
mst/
> =

> Email me now on mst (at) shadowcat.co.uk and let's chat about how our Cat=
alyst
> commercial support, training and consultancy packages could help your tea=
m.
> =

> _______________________________________________
> 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.u=
k/
> Dev site: http://dev.catalyst.perl.org/



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110302/33efc=
b52/attachment.htm


More information about the Catalyst mailing list