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