On Fri, 7 May 2004, Frank Wiles wrote: > Well the source leads me to believe they already know it doesn't work > with mp2. To quote it "TODO - Should check for mod_perl 2 and do > the right thing there".
I made some changes to make Apache-DBI work with mod_perl2 a few months ago. It works great for me. I gave them to Ask, but nothing was apparently done with it. It's not elegant, but it works for me. Here is the diff: --- DBI.pm Tue Feb 17 16:18:50 2004 +++ DBI.pm.new Thu Feb 26 14:52:49 2004 @@ -8,6 +8,7 @@ use Carp qw(carp); require_version DBI 1.00; +use constant MP2 => $mod_perl::VERSION >= 1.99; $Apache::DBI::VERSION = '0.94'; @@ -32,9 +33,14 @@ # provide a handler which creates all connections during server startup # TODO - Should check for mod_perl 2 and do the right thing there - carp "Apache.pm was not loaded\n" and return unless $INC{'Apache.pm'}; - if([EMAIL PROTECTED] and Apache->can('push_handlers')) { - Apache->push_handlers(PerlChildInitHandler => \&childinit); + if (MP2) { + Apache->server->push_handlers(PerlChildInitHandler => \&childinit); + } + else { + carp "Apache.pm was not loaded\n" and return unless $INC{'Apache.pm'}; + if([EMAIL PROTECTED] and Apache->can('push_handlers')) { + Apache->push_handlers(PerlChildInitHandler => \&childinit); + } } # store connections push @ChildConnect, [EMAIL PROTECTED]; @@ -94,12 +100,23 @@ # this PerlCleanupHandler is supposed to initiate a rollback after the script has finished if AutoCommit is off. my $needCleanup = ($Idx =~ /AutoCommit[^\d]+0/) ? 1 : 0; # TODO - Fix mod_perl 2.0 here - if(!$Rollback{$Idx} and $needCleanup and Apache->can('push_handlers')) { - print STDERR "$prefix push PerlCleanupHandler \n" if $Apache::DBI::DEBUG > 1; - Apache->push_handlers("PerlCleanupHandler", \&cleanup); - # make sure, that the rollback is called only once for every - # request, even if the script calls connect more than once - $Rollback{$Idx} = 1; + if (MP2) { + if(!$Rollback{$Idx} and $needCleanup) { + print STDERR "$prefix push PerlCleanupHandler \n" if $Apache::DBI::DEBUG > 1; + Apache->server->push_handlers("PerlCleanupHandler", \&cleanup); + # make sure, that the rollback is called only once for every + # request, even if the script calls connect more than once + $Rollback{$Idx} = 1; + } + } + else { + if(!$Rollback{$Idx} and $needCleanup and Apache->can('push_handlers')) { + print STDERR "$prefix push PerlCleanupHandler \n" if $Apache::DBI::DEBUG > 1; + Apache->push_handlers("PerlCleanupHandler", \&cleanup); + # make sure, that the rollback is called only once for every + # request, even if the script calls connect more than once + $Rollback{$Idx} = 1; + } } # do we need to ping the database ? -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html