On 2/21/06, Ed Pigg <suppressed> wrote:
>
> On Feb 20, 2006, at 6:51 PM, Ed Pigg wrote:
>
> > package MyApp;
> > use DBI;
> > use base 'CGI::Application';
> > use CGI::Application::Plugin::Session;
> > use CGI::Application::Plugin::DBH (qw/dbh_config dbh/);
> > use CGI::Application::Plugin::Authentication;
> >
> > __PACKAGE__->authen->config(
> > # DRIVER => [ 'DBI',
> > # DBH => $self->dbh,
> > # TABLE => 'user_info',
> > # CONSTRAINTS => {
> > # 'user_info.user_name' => '__CREDENTIAL_1__',
> > # 'user_info.user_passwd' => '__CREDENTIAL_2__',
> > # } ],
> > DRIVER => [ 'Generic', { foo_user => 'foo', bar_user => 'bar' } ],
> > STORE => 'Session',
> > POST_LOGIN_RUNMODE => 'welcome',
> > );
> >
> > __PACKAGE__->authen->protected_runmodes('welcome');
>
> Ok. I slept on it and wrote a quick test for CAP::DBH to make sure I
> could get a database connection. I was able to get a successful test
> of DBH. So the problem must be in the authen->config Driver setup or
> how I'm calling authen. As I stated before, the Generic and Dummy
> drivers work as I expect and as documented.
In the configuration, you are calling $self->dbh to pass in the
database handle, but since you are configuring everything in the
global scope of the application, $self is not defined yet. So you
either need to move the entire configuration into a cgiapp_init block,
or just remove the DBH option completely, since by default the Authen
plugin will call $self->dbh to get a database handle if none was
passed in (that gives you the benefit of lazy loading the database
handle as well, since it will only be called if it is needed).
Cheers,
Cees
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.