[Catalyst] How and where to run a method at Catalyst start up?

Emmanuel Quevillon tuco at pasteur.fr
Fri May 15 10:12:27 GMT 2009

Hi all,

I am developing a Catalyst App and I'd like to know how to launch a
method at Catalyst start up?
The idea is to check and create some kind of a data structure that
will be loaded into memory (__PACKAGE__->{mydata} = { ... }) of my
application and will be then accessible at anytime from anywhere in
any controller as

sub foo: Local {
  my($self, $c) = @_;

  my $personnal_data = $self->_get_mydata();



sub get_mydata will reside into MyApp.pm

But how can I access my database within MyApp.pm ?
I tried (in MyApp.pm):

sub _test {

  my $self = shift;
  @rs = $self->comp('MyApp::DB::Table')->search({ id => { '>' => 2 } });

  #If I print each values of @rs
  #it prints something like 'MyApp::DB::Table=HASH(....)
  #But from each item of my array, if I tried any call to
  #column sub (like $_->id()) I get 'Unkown error'
  #Also it looks like $_ is a 'DBIx::Class' only


Has somebody any clue how could I solve my problem
Thanks in advance


Emmanuel Quevillon
Biological Software and Databases Group
Institut Pasteur
+33 1 44 38 95 98
tuco at_ pasteur dot fr

More information about the Catalyst mailing list