[Catalyst] proper flow control with $c->foward, in search of greater grok

Tommy Butler ace at tommybutler.me
Mon Jan 4 19:48:33 GMT 2010


Friends,

What I know about flow control using $c->forward/detach/visit/go is
contrived at best.  I'm struggling to grasp it completely due to the
various way the mechanism can be invoked, and because of the multiple
(and inconsistent) sources of information on the topic that I've found
in books and on websites (including the CPAN docs for Catalyst which
still leave a bit to be desired--at least for myself).  I am looking for
something complete and exhaustive detailing every way to invoke
$c->forward.  I'd also like to get some affirmation that the things I
think I understand are correct.

So the summation of what I'm looking for is:
   1) are my suppositions correct as outlined below, and
   2) what am I missing?

Your valued help and time is extremely appreciated.

# WHAT I (THINK) I KNOW
I understand you can invoke forward in several ways, and that it can
only ever return one value, if needed.  If I also understand correctly,
should you call it without the optional final listref of extra
parameters, that the original @_ from the invoking cat action is passed
on implicitly.

# FORWARDING TO AN ACTION IN YOUR OWN NAMESPACE
$c->forward('another_action');

# FORWARDING WITH URL SYNTAX
$c->forward('/groceries/vegetables/carrots');

# FORWARDING WITH ARGUMENTS
$c->forward('yet_another_action', [ 1, 2, 'buckle my shoe' ]);

# FORWARDING TO AN ACTION IN SOME OTHER NAMESPACE
# THAT MIGHT NOT BE ACCESSIBLE AS A URL
my $dbix_query = $c->forward(
   'Reports::Custom::TodaysPerformance',
   'todays_performance_detailed',
   [ {
      report_id    => $report_id,
      order_by     => 'record_date',
      sort_order   => 'ASC',
      paginate     => 0
   } ]
);

# FORWARDING TO A VIEW?
# not sure if you can pass arguements here, nor am I sure why I'm required
# to fully qualify the namespace starting at 'MyApp' and why I am not
required
# to do so in the example immediately above this one
$c->forward('MyApp::View::MP3');

-- 
Tommy Butler




More information about the Catalyst mailing list