[Catalyst] running a function once on all requests

Steve Francia steve at takkle.com
Mon Jun 4 19:57:37 GMT 2007


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/Ma=
nual/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 ) =3D @_;
        $c->stash->{ controller } =3D $c->namespace;
    }

in the root controller (Root.pm). It works until I chain across more
than one controller.
Instead of the first, it gives me last controller in the chain, which
leads me to believe that this method is either called once for each
controller or called only once, but from the last controller in the chain.

Perhaps there is a different approach with autochaining I should try.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070604/e22a3=
d14/attachment.htm


More information about the Catalyst mailing list