
jester at panix
Jun 18, 2009, 2:50 AM
Views: 509
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/
|