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

John Napiorkowski jjn1056 at yahoo.com
Tue Aug 15 18:39:04 CEST 2006


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}

Okay, I guess I can see the value of that, but it caused me serious namespace collision trouble until I understood it.  But here is the not intuitive thing for me.  If you have the opposite, such as you define $self->{xxx} to something using say a local accessor then it doesn't also mirror this to $self->config->{xxx} so it works one way and not the other.

Does this cause trouble for anyone else?  To be honest I spent several hours today figuring this out, but then again I am not the wisest programmer around, just bloody minded enough to plod along.  Is there a reason it works this way? And most importantly, if so what do we all think could be a good way to document it?

--john





More information about the Catalyst mailing list