[Catalyst] relationship between $self->config->{xx} and $self->{xx}

Matt S Trout dbix-class at trout.me.uk
Tue Aug 15 19:03:10 CEST 2006


John Napiorkowski wrote:
> Strange things going on.
> 
> If you define something in a controller's config like so:
> 
> __PACKAGE__->config(
> 
>     title        => 'Headline News',
>     description    => 'News from around the World',
>     
> );
> 
> It looks like I can access this two ways:
> 
> $self->config->{title}
> $self->{title}

Config is a class method. That info is merged with config from the app (so 
your config file etc. data gets added) and the merged data is handed to the 
Controller's new().

 From within a View/Model/Controller you should *never* be calling 
$self->config; it won't contain data from ConfigLoader or the app config so 
it's liable to be wrong. Use the data in the object itself. I usually add an 
accessor every time I add a config key (via __PACKAGE__->mk_accessors) and 
then use that.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list