[Catalyst] In search of a clue ... how do I access _PACKAGE_->config values , or more specifically, values put into myapp.yml ?

Kieren Diment diment at gmail.com
Mon Nov 5 21:36:43 GMT 2007


On 6 Nov 2007, at 08:17, John Goulah wrote:

> On Nov 5, 2007 12:37 PM, Joe Landman <landman at scalableinformatics.com>
> wrote:
>
>> Hi folks:
>>
>>   This should be an easy one.  I read and read and read.  The  
>> manual is
>> fine, but my reading skills may be in doubt.
>>
>>   This is what I want to do.  I want to set a simple variable named
>> myvar in myapp.yml.  Then I want to pick it up later on.
>>
>> So far so good, I have
>>
>> myvar:  blahblahblah
>>
>> in myapp.yml at the top of my application tree (in the same  
>> directory as
>>  lib, script, root, ...)
>>
>> Now, in one of my controllers, I want to get access myvar.  I  
>> thought I
>> can get at it like this:
>>
>>        $c->config->{myvar}
>> <http://dev.catalyst.perl.org/>
>
>

Silent failure when your yaml is bad can be a problem.  Here's a  
useful one liner that will pass silently or fail noisily.

perl -MYAML=LoadFile -e 'LoadFile $ARGV[0]'

also consider using .conf instead, it's less easy to get wrong.  Once  
you've got your app config working try this and swap out myapp.yml  
for myapp.conf:

perl -Ilib -e 'use MyApp; use Config::General; Config::General->new- 
 >save_file("myapp.conf", MyApp->config);'

There's probably some cruft in the .conf file you need to remove, but  
it's still less painful than yaml imo.

>
> Looks right, did you load the ConfigLoader plugin (
> http://search.cpan.org/~bricas/Catalyst-Plugin-ConfigLoader-0.18/ 
> lib/Catalyst/Plugin/ConfigLoader.pm)
> ?
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/ 
> catalyst at lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/



More information about the Catalyst mailing list