[Catalyst] running a function once on all requests

Steve Francia steve at takkle.com
Mon Jun 4 17:59:33 GMT 2007

I have a routine I would like to run once for each request.

After reading through the docs, I think I have found a good approach and
am wondering what others have done.

I created a base controller which uses base 'Catalyst::Controller' .
Inside the base controller I create a begin function:

    sub begin : Private {
        my ( $self, $c ) =3D @_;

        $c->stash->{ controller } =3D $c->namespace;

In all my other controllers I use this base class.

If I want to add a controller specific begin routine to a controller I
place the following in that controller class:

    sub begin : Private {
        my ( $self, $c ) =3D @_;


Anyone know of any good reason to do it differently, or has anyone used
other strategies in the past?

Steve Francia

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070604/15508=

More information about the Catalyst mailing list