[Catalyst] Reading Database At Startup

Ovid publiustemp-catalyst at yahoo.com
Sun Aug 16 15:09:40 GMT 2009


Hi all,

This should be painfully obvious, but I don't see it :)

For a personal project, I want users to be able to click on a letter and get a list of countries starting with that letter.  I can do this:

    my $letters = $c->model('DB')->storage->dbh->selectcol_arrayref(
        'select distinct(substr(name,1,1)) as letter from country order by letter'
    );
    $c->stash->{letters} = $letters;

 
But the country list is static and I want this available at startup.  'sub begin' fails because that's called once per request, not once per app.

What's the recommend way of handling this?  (I'm using DBIx::Class for the model)

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6




More information about the Catalyst mailing list