Hi all,

I was bitten by the naming of one of my controller methods. After digging a
little into that I found that the method name "actions" was not the best
idea to use. It is in catalyst terms a keyword (actually an attribute) of
Catalyst::Controller where also my controller inherits from.

Although this is definitly a thing you should not do, all that was reported
to me during the failing startup was, that one of my controller was trying
to call a method on an undefined value (which was $c, the context object
actually). This was very misleading and quite hard to find. Others might
fall into the same pit.

With the powers of moose it should be possible to know that an attribute
"actions" (wich an accessor of the same name") should not be allowed to be
overridden by a method of a child class. This could be reported to the user
(while still failing to start up).

A test for showing the behaviour is attached as simple patch against
5.80003. It just shows the failure. If I know what the intended behaviour
should be, I can produce a more appropriate test.

Cheers and comments welcome.

+rl
-- 
Roland Lammel
QuikIT - IT Lösungen - flexibel und schnell
Web: http://www.quikit.at
Email: [email protected]

"Enjoy your job, make lots of money, work within the law. Choose any two."
diff -r -N Catalyst-Runtime-5.80003/t/lib/TestApp/Controller/Keyword.pm Catalyst-Runtime-5.80003-IwCJtd/t/lib/TestApp/Controller/Keyword.pm
0a1,12
> package TestApp::Controller::Keyword;
> 
> use strict;
> use base 'Catalyst::Controller';
> 
> sub actions : Local {
>     my ( $self, $c ) = @_;
>     die("Call to controller method without context not allowed!") unless $c;
>     $c->res->output("Test case for using keywords with catalyst\n");
> }
> 
> 1;
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to