[Catalyst] Re: running a function once on all requests
A. Pagaltzis
pagaltzis at gmx.de
Wed Jun 6 06:08:45 GMT 2007
* Eden Cardim <edencardim at gmail.com> [2007-06-04 22:15]:
> sub auto : Private {
> my($self, $c) = @_;
> push @{$c->stash->{controllers}}, $self->namespace;
> return 1;
> }
>
> # in Root
> sub end : Private {
> my($self, $c) = @_;
> $c->stash{controller} = $c->stash->{controllers}[0];
> }
Not that this is the best way to do it (see Matt’s post for
that), but if you’re always going to pick the bottom element,
why’re you using a stack at all?
sub auto : Private {
my ( $self, $c ) = @_;
$c->stash->{ controller } ||= $self->namespace;
return 1;
}
Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>
More information about the Catalyst
mailing list