[Catalyst] Attribute::Handlers wont work in own classes under catalyst

John Napiorkowski jjn1056 at yahoo.com
Thu Aug 30 14:08:41 GMT 2007


--- Nilson Santos Figueiredo Junior <acid06 at gmail.com>
wrote:

> On 8/29/07, Felix Antonius Wilhelm Ostmann
> <ostmann at websuche.de> wrote:
> > after a few tests we gone use this classes under
> catalyst ... and ...
> > dont work :-/ under catalyst our classes dont use
> Attribute::Handlers
> > :-/ we declare UNIVERSAL::Property and then use
> "sub nondigit : Property
> > { defined && !m{[0-9]} }" (see the code)
> 
> Catalyst breaks regular subroutine attributes.
> Apparently, it tries to
> parse them all so other code never gets the chance
> to parse them. I've
> seen this problem before while using a module (which
> used subroutine
> attributes) along with Catalyst and I decided to
> work around it
> instead of looking for a proper fix.
> 
> Good luck. Hopefully someone else can come up with
> solution other than
> using Catalyst's own attribute handling framework.
> 
> -Nilson Santos F. Jr.

Do we have the same problem with non action
subroutines in a Controller?  Because we have to
remember that an action declared in a controller is
being wrapped into it's own class, so we have to
expect that sub won't work quite the same way as plain
old Perl packages.  However 'normal' subs should work
fine.  I'm not so familiar with the attribute handling
module you've talked about, so I can't really be sure,
but I'd be curious if someone could try:

sub my_action :Local {
 my ($self, $c) = @_;
}

sub not_an_action :CustomAttribute {
 my $self = shift @_;
}

This trick might also work in a custom action class.

Try to think of Catalyst Components as wrappers to
other stuff and it will help.  Definitely it's great
practice to design stuff that works as a plain old
perl object and then bring it into Cat using action
classes, models, etc.




       
____________________________________________________________________________________
Choose the right car based on your needs.  Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/



More information about the Catalyst mailing list