[Catalyst-dev] Problem with Catalyst::Controller handling CreateToken attributes

Edwin Crockford ecrockford at invicro.com
Fri Jan 18 15:35:19 GMT 2013


Have recently been porting an existing Catalyst site to run under Centos 
6 (using the current CPAN version of Catalyst). The site would not start 
and gave the following error message:

Can't locate 
Catalyst/Action/Catalyst/Controller/RequestToken/Action/CreateToken.pm 
in @INC (@INC contains: /opt/src/ipacs/script/../lib 
/opt/invicro/lib/perl5/5.10.1/x86_64-linux /opt/invicro/lib/perl5/5.10.1 
/opt/invicro/lib/perl5/site_perl/5.10.1/x86_64-linux 
/opt/invicro/lib/perl5/site_perl/5.10.1 .) at 
/opt/invicro/lib/perl5/site_perl/5.10.1/Catalyst.pm line 2485.

It should be trying to include 
Catalyst/Controller/RequestToken/Action/CreateToken.pm but 
Catalyst/Action/ has been tacked on the front of the path.

The method calls generating the problem looked something like this:

sub index  : Path  :  CreateToken  {

After lengthy investigation I discovered that the problem was in the 
Catalyst::Controller module around line 422.

             while (my ($new_key, $value) = each %new_attrs){
                 my $new_attrs = $key eq $new_key ?
                     { $new_key => [$value] } :
                     $self->_parse_attr($c, $name, $new_key => $value );
                 push @{ $final_attributes{$_} }, @{ $new_attrs->{$_} } for keys %$new_attrs;
             }


$new_key (as return by the _parse_CreateToken_attr method of Catalyst/Controller/RequestToken.pm) is ActionClass
while $key is CreateToken so $self->_parse_attr is called again which adds the unwanted Catalyst/Action to the front of the
class name. This generates the error above.

I fixed the problem temporarily by merely skipping the equality test when the attribute contained 'Token'. This made
the site work again but this is truely inelegant.

Is this a known problem with a fix or can anyone guide me to a better way of fixing it?

Thanks
Edwin





More information about the Catalyst-dev mailing list