FAQ
I included this as part of a long question yesterday about
testing, but I realize that perhaps it's better as a separate
question.

Basically, I have a standard Catalyst config file, where
the database connection section looks like this:

<Model::LibraryDB>
schema_class Library::Schema::Main
connect_info DBI:mysql:host=localhost;database=library_test
connect_info library_test_user
connect_info library_test_password
<connect_info>
mysql_enable_utf8 1
</connect_info>
</Model::LibraryDB>

I'd like to get access to this information from a script
running outside of Catalyst. How can I do this cleanly?
I grab the file with:

my %config = Config::General->new($config_file)->getall;

But then this leaves me with ugliness like

$my user_name = $config{'Model::LibraryDB'}->{'connect_info'}->[1];

And getting the database name requires regexing the first
connect_info line. Is there some other Cat-approved way of
setting up the config file so that this information is easily
available both to an external program and to Cat? I suppose I
can put this into a plain variable up front, switch on
variable interpolation, and then include the variables in the
connect info, but I haven't seen this done with Cat before.

Jesse Sheidlower

Search Discussions

  • Peter Edwards at Jun 18, 2009 at 12:51 pm
    2009/6/18 Jesse Sheidlower <jester@panix.com>
    Basically, I have a standard Catalyst config file, where
    the database connection section looks like this:
    I'd like to get access to this information from a script
    running outside of Catalyst. How can I do this cleanly?
    Hi Jesse, I wrote an advent calendar article on this (bit out of date, but
    should do)

    http://www.catalystframework.org/calendar/2007/14

    on CPAN see

    http://search.cpan.org/perldoc?Config::JFDI

    Cheers,
    Peter
    http://perl.dragonstaff.co.uk
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090618/61e8214f/attachment.htm
  • Jesse Sheidlower at Jun 18, 2009 at 2:31 pm

    On Thu, Jun 18, 2009 at 01:51:28PM +0100, Peter Edwards wrote:
    2009/6/18 Jesse Sheidlower <jester@panix.com>
    Basically, I have a standard Catalyst config file, where
    the database connection section looks like this:
    [...]
    I'd like to get access to this information from a script
    running outside of Catalyst. How can I do this cleanly?
    Hi Jesse, I wrote an advent calendar article on this (bit out of date, but
    should do)
    Thanks, Peter. This is interesting, and I think I'll use this
    for something or other.

    But in this case, it doesn't really address the main question,
    which is that fishing this variable out of the haze in which
    it's currently in in the config file is a PITA.

    Thinking about it since I sent the original message, though, I
    think I will put them into variables that I will interpolate.

    Jesse Sheidlower

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJun 18, '09 at 9:50a
activeJun 18, '09 at 2:31p
posts3
users2
websitecatalystframework.org
irc#catalyst

2 users in discussion

Jesse Sheidlower: 2 posts Peter Edwards: 1 post

People

Translate

site design / logo © 2022 Grokbase