Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Action attributes

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


forihrd at gmail

Jun 5, 2009, 8:35 PM

Post #1 of 4 (506 views)
Permalink
Action attributes

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

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


bobtfish at bobtfish

Jun 6, 2009, 9:36 AM

Post #2 of 4 (464 views)
Permalink
Re: Action attributes [In reply to]

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


_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


dbix-class at trout

Jun 8, 2009, 12:07 PM

Post #3 of 4 (456 views)
Permalink
Re: Action attributes [In reply to]

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/

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


forihrd at gmail

Jun 14, 2009, 12:55 AM

Post #4 of 4 (394 views)
Permalink
Re: Action attributes [In reply to]

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

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.