[Catalyst] Re: question for mst : using $c->config->{blah} ...

Matt S Trout dbix-class at trout.me.uk
Mon Aug 4 17:48:40 BST 2008

On Mon, Aug 04, 2008 at 01:59:06PM +0200, Daniel McBrearty wrote:
> On Mon, Aug 4, 2008 at 11:14 AM, Matt S Trout <dbix-class at trout.me.uk> wrote:
> > On Sun, Aug 03, 2008 at 06:30:02PM +0200, Daniel McBrearty wrote:
> >> wait, it is on $self not $c, so my reservations don't really apply.
> >>
> >> but what about reall config stuff that can change from one
> >> installation to another? then you have to do $c->config->{my_var},
> >> right?
> >
> > How isn't something like connect_info real config?
> >
> By "real config", I mean stuff which is entirely specific to the app,
> and not generic for a particular Cat component. An example might
> something like email addresses that input from a certain form is sent
> to. Maybe "real" wasn't the best word.

You're drawing a line that doesn't exist.

Your DBIC model is specific to your app.

An email address that gets sent to is model or controller config - the
example I showed you is a mailer form app - and the addresses and other
form info get passed to the form manager model.

> In my app, I have done it rather differently - anything that is
> "config" is in the config file - class level or whatever. And
> everything is accessed using $c->config->{whatever}
> The reason I like this is simplicity - if it says "config", I know
> where to find it, end of story. Just a personal preference.

The reason I hate it is that it's a god object.

But if it works for you for the moment, I wouldn't worry too much about it.

Once the app/ctx split stuff comes in you'll probably want to rethink so
you can have multiple copies of your app in the same process.

But until then, I'd strongly recommend against it for new code but I don't
see any business value to going back and changing old code that already
works that way.

      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