[Catalyst] Note re config - Documenters and module authors please take note

Matt S Trout dbix-class at trout.me.uk
Thu Feb 7 12:46:23 GMT 2008


I keep seeing people doing

__PACKAGE__->config->{foo}{bar} = 'value';

This is -not- correct usage, is -not- safe and has undefined results. I've
hacked the implementation of config around quite a bit to minimise this but
without doing highly expensive (and potentially also dangerous) deep clones
everywhere it can't be made safe.

The correct thing to do is -

__PACKAGE__->config(
  foo => { bar => 'value' }
);

Basically, only ever call ->config->{... for getting values.

If you need to set, call the method as demonstrated above.

Any documentation or code using the other approach (including some in cat
core) is -wrong- and we need to correct it.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://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/



More information about the Catalyst mailing list