[Catalyst] Note re config - Documenters and module authors
pleasetake note
Matt Pitts
mpitts at a3its.com
Thu Feb 7 13:33:33 GMT 2008
Would it be sane to break down the hash merging magic of $c->config into
separate methods? For example, for doing large-scale, pre-setup config
we could have
__PACKAGE__->add_config({ name => 'MyApp', ... });
Which will make use of 'merge_config_hashes' and apply the
C::D::Inhertiable kludging. Then __PACKAGE__->config could just be a
getter of the whole app config which wouldn't need C::D::Inheritable
kludging to prevent the creation a setter in __PACKAGE__.
So, doing things like
__PACKAGE__->config->{foo}{bar} = 'value';
is still safe.
Or, is there some more magic to Class::Data::Inheritable that I'm
missing?
v/r
-matt
> -----Original Message-----
> From: Matt S Trout [mailto:dbix-class at trout.me.uk]
> Sent: Thursday, February 07, 2008 7:46 AM
> To: catalyst at lists.scsys.co.uk
> Subject: [Catalyst] Note re config - Documenters and module authors
> pleasetake note
>
> 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/
>
> _______________________________________________
> 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.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
More information about the Catalyst
mailing list