[Catalyst] Setting config after setup has been run is not allowed.

Bill Moseley moseley at hank.org
Fri Sep 25 13:37:51 GMT 2015

I'm confused about this rather stern note in Catalyst.pm.

Is this the following wrapper related to the text in the NOTE?

B<NOTE:> you MUST NOT call C<< $self->config >> or C<< __PACKAGE__->config
as a way of reading config within your code, as this B<will not> give you
correctly merged config back. You B<MUST> take the config values supplied to
the constructor and use those instead.


around config => sub {
    my $orig = shift;
    my $c = shift;

    croak('Setting config after setup has been run is not allowed.')
        if ( @_ and $c->setup_finished );


I understand the NOTE for Model/View/Controllers where the component's
__PACKAGE__->config is merged in with the application config for that
component.   Calling $self->config won't be the same thing passed to the
component's constructor.

But, what's the issue with calling $c->config( foo => 123 ) at runtime?
Or even $c->config( \%new_config )?

Note that wrapper only applies to calling config on the app class, and does
not apply to Model/View/Controllers.

Is there some other issues I'm missing?   What problem is that wrapper
trying to prevent?


Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/catalyst/attachments/20150925/ac079e36/attachment.htm>

More information about the Catalyst mailing list