[Catalyst] ConfigLoader and components

Nathan Kurz nate at verse.com
Wed May 10 06:40:52 CEST 2006


I've been beating my head against this for an hour now, and think I
must be missing something.  How can I use ConfigLoader to let me set
the database dsn in myapp.yml, and pass that along to the component
I'm deriving from Catalyst::Model::DBIC::Schema?

For a plugin, I think I'd just need to override setup(), but for a
component do I override new()?  COMPONENT()?  Looking at the code in
setup_components(), it seems I should be able to do something like:

App::Model::DB.pm:
  sub new {
      my $c = shift;
      my ($config) = @_;
      ...do something with $config...
      return $c->NEXT::new(@_);
  }
----------------------
app.yml:
  Model::DB:
     dsn: 'dbi:SQLite:dbname=/var/www/sqlite/app.db'

But I can't make this work.   What's the right way to do this?  

(sorry if I'm sounding incoherent---I'm feeling that way too)

Nathan Kurz
nate at verse.com




More information about the Catalyst mailing list