Skip Menu |

This queue is for tickets about the CGI-CRUD CPAN distribution.

Report information
The Basics
Id: 57081
Status: resolved
Priority: 0/
Queue: CGI-CRUD

People
Owner: Nobody in particular
Requestors: PJNEWMAN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.05
Fixed in: (no value)



Subject: Improvement: Config via file rather than env vars
Thanks for some great work, this is exactly what I've been looking for and I'm now using it in a few applications. For various reasons, I'd like to have all the database and file stuff configured within cruddy.pl, rather than having to use environment variables. The following patches do that, while still keeping the old functionality, so you might like to add them. cruddy.pl: 62c77,78 < my $r = new CGI::CRUD::CGIOutputFastTemplate($q) or exit 0; --- Show quoted text
> my $r = new CGI::CRUD::CGIOutputFastTemplate($q, undef, {dsn
=> 'dbi:mysql:db:localhost:3306', user => 'user', pass => 'pass'}, "cruddy.tpl", "/path/to/admin") or exit 0; Show quoted text
> #my $r = new CGI::CRUD::CGIOutputFastTemplate($q, undef, undef) or
exit 0; CGI/CRUD/CGIOutputFastTemplate.pm 27c27 < --- Show quoted text
> my $DEFAULT_TPL_PATH = '/var/www/cruddy';
33c33 < my ($q,$defaults) = @_; --- Show quoted text
> my ($q,$defaults, $dbi, $tplf, $tplp) = @_;
36a37,39 Show quoted text
> $DEFAULT_TPL_MAIN = $tplf if defined($tplf); > $DEFAULT_TPL_PATH = $tplp if defined($tplp); >
38c41 < unless ($self->{dbh} = DBI->connect(undef,undef,undef,{ PrintError => 1, RaiseError => 0, AutoCommit => 1, })) --- Show quoted text
> unless ($self->{dbh} = DBI->connect($dbi->{dsn},$dbi->{user},$dbi- >{pass},{ PrintError => 1, RaiseError => 0, AutoCommit => 1, }))
Thanks, PN
You can probably ignore the above. I've just discovered the joys of Perl's BEGIN statement. For the benefit of anyone else who stumbles across this bug, just stick the following, or similar, before the "use" statements in cruddy.pl. BEGIN { $ENV{'DBI_DSN'} = "dbi:mysql:database:localhost:3306"; $ENV{'DBI_USER'} = "username"; $ENV{'DBI_PASS'} = "password"; $ENV{'CRUDDY_FAST_TEMPLATE_PATH'} = "/path/to/cruddy/template"; $ENV{'CRUDDY_FAST_TEMPLATE_MAIN'} = "cruddy.tpl"; }