Example of pulling the standard catalyst config into a "command-line-type-usage" script (works nicely from the scripts/ directory):
use FindBin qw($Bin); use Path::Class; use lib dir($Bin, '..', 'lib')->stringify; # cross-platform # Now that we have the local LIB directory in our @INC path, get the module: use MyApp::Schema::DB; use Config::General; use strict; # Get info from the config file my $conf = new Config::General( file( $Bin, '..', 'myapp.conf' ) ); my %conf = $conf->getall; my $dbi = $conf{'Model::MyApp'}{connect_info}; my @dbi = map{ $dbi->{$_} } qw/dsn user password/; # Connect to database my $schema = MyApp::Schema::DB->connect( @dbi ); #...etc On Fri, Jun 8, 2012 at 1:23 PM, Thomas Klausner <d...@cpan.org> wrote: > Hi! > > On Fri, Jun 08, 2012 at 02:05:31PM -0400, Luis Muñoz wrote: > > > But still, I would like to have access to the configuration data (for > > instance, how to setup the database/ldap/whatever Model, etc). Does > > that happen as well when using the class method? > > We pack our config (which basically is a big hash) in a class. To > provide the config to Catalyst, we use the class in my_app.pl (which is > like my_app.(yml|json|ini|...). If we need the config in some other > scripts, we just use the class there. > > The non-Web code lives in classes (eg DBIC) that are used via Models in > Catalyst, or directly (or some Model-like wrappers, if it needs to be) > in other contexts. > > Greetings, > domm > > > -- > #!/usr/bin/perl http://domm.plix.at > for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/} > > _______________________________________________ > List: Catalyst@lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: > http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ > -- Will Trillich :: 812.454.6431 “Waiting for perfect is never as smart as making progress.” -- Seth Godin
_______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/