Jonathan Rockway wrote:
* On Mon, Feb 23 2009, Jason Gottshall wrote:
Oleg Pronin wrote:
  I use many actions that take params from config in runtime, for example
  sub pay_for_vip : Private {
       ...
       my $price = $c->cfg->{vip}{price};
  }
As I understand it, this is NOT the way config is intended to
work. All the config for your component (controller in this case) is
passed to the constructor at setup time; all you need to do is make
accessors for whatever you want access to:

  __PACKAGE__->mk_accessors(qw/vip/);

  sub pay_for_vip : Private {
      ...
      my $price = $self->vip->{price};
  }

Yes, exactly.

This is another case of the all-too-frequent "change Catalyst so that I
won't have to change any code in my poorly-implemented app".
Jeez. That's a little harsh, though I sympathise with the general point.

We use the Catalyst config file to initialize Catalyst components, to initialise non-Catalyst configuration objects, and also to provide via config() a simple runtime interface to 'get this key/value pair'. We store other (runtime) conf values in the db, wrapped with memcached, to avoid having to deploy a config file if we need timely changes. Many of our conf values are shared between components, not directly relevant to components, or are most readably kept together as a discrete configuration set, rather than added per component. Finally, given the size of our conf file, I don't think we'd want to clutter either our packages with accessors, or our project with classes that merely wrap configuration sets.
I don't think the patch will be harmful, though, so if there is one we
might as well apply it.  But it's a lot easier to not misuse config than
it is to patch Catalyst to make the misuse faster.
I can't see anywhere in the docs where this 'intended use' is stated. That's not to say that it isn't there.

Having said all that, our app must call config 10s of million times a day, and we've never perceived it to be a bottleneck.

Regards,
David


_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to