[Catalyst] Action attributes
Matt S Trout
dbix-class at trout.me.uk
Mon Jun 8 19:07:57 GMT 2009
On Sat, Jun 06, 2009 at 02:35:53PM +1100, Илья wrote:
> Hi there,
> we use Catalyst about year and one thing make a lot of pain. When you
> make typo in action attribute name Catalyst silently eat it. For
> example:
>
> sub foo : Loacal Arg(1) {
>
> }
>
> will be work, but Arg(1) just do nothing.
>
> Now we use few additional attributes and I add trivial check in
> Our::Catalyst::Action:
>
> my @correct_names = qw<
> Path
> Private
> Global
> Local
> Regex
> LocalRexgex
> Args
> Chained
> CaptureArgs
> PathPart
>
> Method
> Secure
> UnSecure
> RestrictTo
> Crumb
> Test
> >;
>
> foreach my $name (keys %$attrs) {
> unless ( first { $name eq $_ } @correct_names ) {
> die "Wrong trait (attribute) $name!";
> }
> }
>
> so it is work for us, but mb better to add something like this in
> Catalyst itself? I can make patch if this helps.
A patch that let you do something like
__PACKAGE__->config(
Dispatcher => {
action_attributes => {
allow => \@list
}
}
);
in MyApp.pm (preferably with the built in ones already in the list) to
turn on strict checking would seem fine to me.
Then the dispatcher could check the actions when each one is registered with
it.
--
Matt S Trout Catalyst and DBIx::Class consultancy with a clue
Technical Director and a commit bit: http://shadowcat.co.uk/catalyst/
Shadowcat Systems Limited
mst (@) shadowcat.co.uk http://shadowcat.co.uk/blog/matt-s-trout/
More information about the Catalyst
mailing list