Re: [Catalyst] Configuring a Controller from the config file
Which contains the class-level defaults. Not application defaults. You should never, ever EVER access $self-config in a model, view or controller object. Your config value will be in $self-{key}. It's considered normal to do package My::Controller::Foo; use strict; use warnings; use parent qw(Catalyst::Controller); __PACKAGE__-mk_accessors(qw(foo bar)); __PACKAGE__-config( foo = 'default_for_foo', bae = { default = 'for_bar' }, ); Thanks a lot! works great :-) ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Configuring a Controller from the config file
On Wed, Jul 30, 2008 at 01:38:00PM +0200, Moritz Onken wrote: Hi, I tried to set some config options for a controller with the config file. YAML-code: --- name: MyApp Controller::Root: key: value I'm using ConfigLoader and the debug shows that it successfully loaded the yaml file. In a method in my Root controller I tried to access those config options via $self-config. Which contains the class-level defaults. Not application defaults. You should never, ever EVER access $self-config in a model, view or controller object. Your config value will be in $self-{key}. It's considered normal to do package My::Controller::Foo; use strict; use warnings; use parent qw(Catalyst::Controller); __PACKAGE__-mk_accessors(qw(foo bar)); __PACKAGE__-config( foo = 'default_for_foo', bae = { default = 'for_bar' }, ); then later in your code just call $self-foo to get the runtime value. -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Directorhttp://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://chainsawblues.vox.com/http://www.shadowcat.co.uk/servers/ ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Configuring a Controller from the config file
Hi, I tried to set some config options for a controller with the config file. YAML-code: --- name: MyApp Controller::Root: key: value I'm using ConfigLoader and the debug shows that it successfully loaded the yaml file. In a method in my Root controller I tried to access those config options via $self-config. I had no luck. $c-config shows the hole config. I could access the config options via $c-config-{Controller::Root} but shouldn't it avaiable via $self- config? What am I missing? moritz ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Configuring a Controller from the config file
On Wed, Jul 30, 2008 at 8:38 AM, Moritz Onken [EMAIL PROTECTED] wrote: --- name: MyApp Controller::Root: key: value I had no luck. $c-config shows the hole config. I could access the config options via $c-config-{Controller::Root} but shouldn't it avaiable via $self-config? You should use either $self-{key} or do the following: __PACKAGE__-mk_accessors( 'key ); and then you can use $self-key to get that information. -Brian ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/