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

Chakkit Ngamsom chakkit at ibiz.co.th
Thu Mar 3 09:14:14 GMT 2011


Thanks Steve, problem solved now.

 

--

Chakkit

 

From: Steve Kleiman [mailto:steve at prodhub.com] 
Sent: Thursday, March 03, 2011 04:34 AM
To: The elegant MVC web framework
Subject: Re: [Catalyst] Catalyst::Plugin::RunAfterRequest and
Catalyst::View::Email?

 

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 sending
a notification after slow processes have been completed e.g. import/export.

 

I'm not sure it's a bug or the limitation of the plugin.

I setup the code something like this:

 

$c->run_after_request(

  sub {

    $c->stash->{email} = {

      from => $from,

      to => $to,

      body => $body,

      header => [

        Subject => '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
value attempted, subscript -1 at
C:/strawberry/perl/site/lib/Catalyst/Dispatcher.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 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."


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 this
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 get
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
Catalyst
commercial support, training and consultancy packages could help your team.

_______________________________________________
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/20110303/bc438408/attachment.htm


More information about the Catalyst mailing list