views:

49

answers:

1

I want to configure all the actions in my controller using my app's config file. According to Catalyst::Controller I can do this in the controller itself:

__PACKAGE__->config(
    action => {
        '*' => { Chained => 'base', Args => 0  },
    },
 );

So I tried this in my config:

<controller Foo>
    <action "*">                                                                
        Chained base
        Args 0
    </action>
</controller>

But I get this error on startup:

Couldn't load class (MyApp) because: Action "*" is not available from 
controller MyApp::Controller::Foo at /usr/local/share/perl/5.10.1/Catalyst/
Controller.pm line 193

It does the same without the quotes around the asterisk. How should I do this?

+2  A: 

This is covered in The Definitive Guide to Catalyst

Grab the downloadable source from that page, unzip it, go to the DwarfChains application in chapter 7, then add the following to dwarfchains.conf:

 <Controller People>
 <action get_ready>
  PathPart nama
 </action>
 </Controller>

 <Controller People::Info>
 <action get_info_ready>
  PathPart siapa
 </action >
 <action create>
  PathPart lagi
 </action >
 <action delete>
  PathPart mengusir
 </action >
 </Controller>

That should more or less demonstrate how to override dispatch by configuration.

singingfish
My point was how cal I configure all actions, using a wildcard. In the controller config I can do (from http://search.cpan.org/~bobtfish/Catalyst-Runtime/lib/Catalyst/Controller.pm#action):'*' => { Chained => 'base', Args => 0 },But using Config::General I get the error above
cubabit
What I'd do in your case is to make a minimal test case using the inline controller configuration as documented, then serialise the config using the following command to see what Config::General is expecting to see: perl -Ilib -e 'use MyApp; use Config::General; Config::General->new->save_file("myapp_testing.conf", MyApp->config);'
singingfish
Sounded like a great idea but unfortunately didn't help. Config::General output: <action><*>Chained base</*></action> which is what I expected. But, putting that into my application config raised the same exception in Catalyst as documented above. Seems the problem is with Catalyst's parsing of the config.
cubabit
Congratulations for finding the second bug reported on Stack Overflow! Please report it at https://rt.cpan.org/Dist/Display.html?Name=Catalyst
singingfish
sorry, incorrect link. Correct place to report the bug is https://rt.cpan.org/Dist/Display.html?Name=Catalyst-Runtime
singingfish