The short answer is that new() doesn't get called.
The "OO" approach is used solely for inheritance, not for a typical object. A contrived example:
package MyHandler; sub handler($$) { my($class, $r) = @_; $class->do_this(); $class->do_that(); } sub do_this { # some default behavior } sub do_that { # some default behavior } package MyHandlerSubClass; use base qw(MyHandler); sub do_this { # do something else } sub do_that { ... }
So in the above example you could extend on MyHandler by subclassing it and changing how do_this() and do_that() behaves. But the handler method will still be called directly without ever "instantiating" anything, you still would be passing the class name.
In your case, since all you're storing is the DBI object, you could store it in $r->pnotes() earlier in the pipeline, or create a wrapper object/function that does that for you:
# I use Apache::DBI and also do something that resembles this in my + code, but YMMV package My::DB; sub connect { my $r = Apache->request; my $dbh =$r->pnotes('MyDBIHandle'); if(!$dbh) { $dbh = DBI->connect(...); $r->pnotes('MyDBIHandle' => $dbh); } return $dbh; }
In reply to Re: mod_perl and objects
by lestrrat
in thread mod_perl and objects
by geektron
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |