I think the confusion arises between class method handlers and object method handlers. Both are available, but the 'official' description of mod_perl 1 method handlers doesn't make the distinction very clear. Both are marked by the special prototype.
A (class) method handler is defined in httpd.conf with something like:
PerlHandler MyPackage->method
Here, as in the example you posted, MyPackage::method gets called with "MyPackage" as the first argument, and the request as the second (as if you'd said MyPackage->method($r) in normal perl). As you've seen, there's no magical new called on the way.
An (object) handler involves the explicit construction of an object at server start-up time, normally in startup.pl. The newly created object is assigned to a package variable, then a method of that variable is specified as a handler
# in startup.pl $My::handler_obj = $MyPackage->new('foo' => 'bar'); # then, in httpd.conf - NOTE THE '$' SIGIL PerlHandler $My::handler_obj->method
In this case, what MyPackage->method will receive as arguments is a blessed reference to $My::handler_obj (not the package name, as above), and secondly the request object, as before.
I don't know whether & how changes to the handler object persist. In particular, if you use object handlers, be careful not to make DBI connections in the new method that gets called in startup.pl, as you'll run into problems. Just use Apache::DBI and connect at handler time; re-use of DBI connections will be dealt with for you.
HTH
ViceRaid
In reply to Re: mod_perl and objects
by ViceRaid
in thread mod_perl and objects
by geektron
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |