J. Shirley wrote:
While an obvious blunder to make while coding, I wasn't alerted to anything and the application started with no warnings and no indication that something was wrong. The only thing is that my 'rpx' method no longer was dispatchable.

Oops.

Hmm, I think that this is actually by design:

http://search.cpan.org/~drolsky/Moose-0.79/lib/Moose/Manual/FAQ.pod#I_created_an_attribute,_where_are_my_accessors?

I'm sure there is a better explanation somewhere, but I can't find it right now.

So, I'm pretty far out of my depth for 5.8 but I'd be happy to commit a failing test case -- is the proper test case a situation like this, and failing if the method doesn't define a dispatchable path or something else? I can imagine this is something that could commonly come up and bite people who aren't careful (or working with thick controllers)

I don't think there's any great way to get around this which I can think of right now.

The best solution I could come up with is to make Catalyst::Controller apply a default attribute trait which warned when (Moose) attributes were added which overrode methods with (perl) attributes.

If you'd like to commit TODO tests (there is already a Moose specific controller in the test suite) which test for an appropriate warning being emitted during app startup, then I'll have a crack at seeing if I can do something sane enough to be maintainable..

> package MyApp::Controller::Auth;
>
> use parent 'Catalyst::Controller';
>
> use Moose;
>
> has 'rpx' => ( is => 'rw' );
>
> sub rpx : Chained('/') Args(0) { }
>
> 1;

Note this pattern works, but is mildly disrecommended going forwards. There are tests in the test suite that it works in basic cases, but it's not what people are using - so I wouldn't be confident it will stay working for non-trivial cases (I have already fixed bugs with doing it this way round).

My Moose native controllers look like this:

package MyApp::Controller::Auth;
use Moose;
use namespace::autoclean;

BEGIN { extends 'Catalyst::Controller'; }

# Attributes and actions

__PACKAGE__->meta->make_immutable; # Note this returns true, so is good for the last line

I did scribble _some_ stuff in Catalyst::Manual::ExtendingCatalyst about this, but if you'd like to add anything (or at least tell us what it's missing currently), that'd be awesome?

Cheers
t0m



_______________________________________________
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