Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Clean access to config from outside Cat?

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


jester at panix

Jun 18, 2009, 2:50 AM

Post #1 of 3 (508 views)
Permalink
Clean access to config from outside Cat?

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

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


peter at dragonstaff

Jun 18, 2009, 5:51 AM

Post #2 of 3 (452 views)
Permalink
Re: Clean access to config from outside Cat? [In reply to]

2009/6/18 Jesse Sheidlower <jester[at]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


jester at panix

Jun 18, 2009, 7:31 AM

Post #3 of 3 (450 views)
Permalink
Re: Clean access to config from outside Cat? [In reply to]

On Thu, Jun 18, 2009 at 01:51:28PM +0100, Peter Edwards wrote:
> 2009/6/18 Jesse Sheidlower <jester[at]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

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

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.