[Catalyst] running a function once on all requests

Matt S Trout dbix-class at trout.me.uk
Tue Jun 5 01:20:43 GMT 2007


On Mon, Jun 04, 2007 at 02:57:37PM -0400, Steve Francia wrote:
> Eden Cardim wrote:
> > On 6/4/07, Steve Francia <steve at takkle.com> wrote:
> >>  Anyone know of any good reason to do it differently, or has anyone used
> >> other strategies in the past?
> >
> > That looks like auto-chaining, you might want to take a look at "auto"
> > actions.
> >
> > http://search.cpan.org/~jrockway/Catalyst-Manual-5.700701/lib/Catalyst/Manual/Intro.pod#Built-in_actions_in_controllers/autochaining
> >
> > http://dev.catalystframework.org/wiki/FlowChart
> >
> It does look like auto-chaining, so perhaps I should restate my original
> question.
> 
> What I want to do is a bit more specific.
> I am using chaining a decent amount, often chaining across different
> controllers.
> 
> The end result of what I want to do is pass into the template (TT) the
> top most level controller name IE the controller closest to root.
> This is accessed using $c->namespace, from within the controller.
> 
> If I use auto-chaining like:
> 
>     sub auto : Private {
>         my ( $self, $c ) = @_;
>         $c->stash->{ controller } = $c->namespace;
>     }

See http://search.cpan.org/perldoc?Catalyst::ActionChain

$c->action->chain->[0]->namespace (note: only valid for :Chained, anything
else leaves $c->action a vanila Catalyst::Action object so check ->isa first)

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.shadowcatsystems.co.uk/ 



More information about the Catalyst mailing list