FAQ
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.

Excuse my ugly English, plz.

Ilya

Search Discussions

  • Tomas Doran at Jun 6, 2009 at 4:36 pm

    On 6 Jun 2009, at 04:35, ???? 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:
    Unfortunately, this is fairly implicit in the design.

    Things like Catalyst::Plugin::Server::XMLRPC use additional
    attributes unknown to Catalyst, without requiring your controllers to
    inherit from a base class defining a "_parse_${custom_attr_name}
    _attr" method - and so this needs to be kept as-if for compatibility.

    However, I'd certainly be fine with a patch to split this behavior
    out of Catalyst::Controller::_parse_attrs, so that you could
    trivially make a controller role or base class outside of Catalyst
    core which was 'strict' about unknown attributes.

    Cheers
    t0m
  • Matt S Trout at Jun 8, 2009 at 7:07 pm

    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/
  • Илья at Jun 14, 2009 at 7:55 am
    Hi,
    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.
    thank you. I will try to add this one!

    Ilya

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJun 6, '09 at 3:35a
activeJun 14, '09 at 7:55a
posts4
users3
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase