Re: Apache::DBI and mod_perl 2.0.1

2005-06-30 Thread Mark A. Downing

On Thu, 30 Jun 2005, Philip M. Gollucci wrote:

Thanks for this Mark.  (Un)fortunately you've been beat to it and there are 
"few" more changes to

get all of it working with mp2.


Very nice. Thanks. Can we get that pushed up to CPAN?


Apache::DBI and mod_perl 2.0.1

2005-06-30 Thread Mark A. Downing

Hi,

I made a couple of changes to Apache::DBI to allow connect_on_init to work
with mod_perl2. Here's the diff if anyone is interested:

diff DBI.pm DBI.pm.old
11,12d10
< use constant MP2 => $mod_perl2::VERSION >= 1.99;
<
37,44c35,37
< if (MP2) {
server->push_handlers(PerlChildInitHandler => 
\&childinit);
< }
< else {
can('push_handlers')) {
push_handlers(PerlChildInitHandler => \&childinit);
<}
---

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);



--Mark


Re: Database handle destroyed.....

2004-05-07 Thread Mark A. Downing
On Fri, 7 May 2004, Stas Bekman wrote:

> Ah, now I understand. Thanks. Which version Mark is using?

I'm running 1.99_12. _13 didn't work for me. I too struggled with Apache::DBI.
If there is something I can do to help, please let me know.

I am a little late to the party, so I'm not sure of what your problem really
is. I caught the post about porting, so I thought I would enter the fray.

--Mark

-- 
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



Re: Database handle destroyed.....

2004-05-07 Thread Mark A. Downing
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



modperl 1 -> modperl 2 problemZ

2003-11-19 Thread Mark A. Downing
I'm struggling with a problem that I originally had years ago.

I have a module that establishes connections to Sybase from Apache.
It works fine, but now I'm trying to make it work with Modperl2 and
not having much luck.

The following code works fine with MP1, but not MP2:

sub connect_on_init { push @ChildConnect, [EMAIL PROTECTED] }
if(Apache->can_stack_handlers) {
   Apache->push_handlers(PerlChildInitHandler => sub {
  for my $aref (@ChildConnect) {
 shift @$aref;
 Apache::Sybase::CTlib->connect(@$aref);
  }
   });
}

It doesn't appear to like my check for can_stack_handlers. I've
tried changing it to Apache->can("push_handlers") and it still
doesn't work.

Any tips or advice... I have been unable to find anything in the
archive and in the new docs.

--Mark

-- 
http://www.wm7d.net/
http://www.wm7d.net/fcc_uls/ulsquery.html

-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html