Richard Clarke wrote:
as you've probably discovered, you're using a feature called 'method handlers' and you should be able to find examples in the eagle book as well.List, Tired of having 10 modules all with near identical handler methods I decided to put the handler method into a superclass and be done with maintaining the same code 10 times. I first tried this a couple of weeks ago and it failed to work, because at the time I couldn't find the reference to OO style handler methods in my Eagle book. Since the mod_perl cookbook is now available on safari I had a quick flick through and noticed a brief mention on OO style handler methods along with the snippet of info I needed i.e. sub handler ($$).
keep in mind that neither book mentions the use of subroutine attributes, which is allowed in 1.3 but the only way in 2.0
sub handler : method {
...
}
[snip]
even though you figured it out already, you might want to check out how Apache::Dispatch does it - there are some security concerns that have been addressed there that you might be interested in.I use a "dispatch" module with a basic handler to choose which module will process a particular uri. It now adds the module to be called like follows, my $sub = join '::', 'Control', ucfirst $module, ucfirst $sub_stage; $r->push_handlers('PerlHandler',$sub->handler);
BTW, for anyone going to ApacheCon this month, I'll be giving a 2 hour presentation on OO mod_perl techniques.
http://www.apachecon.com/html/session-popup.html?id=669
the actual contents differ a bit from the outline - if you were at YAPC::NA it's pretty much the same as the middle part of that talk. basically, the first 25% is about standard OO like sub handler ($$), while the rest shows how to do augment core mod_perl via some really cool subclassing.
cya there
--Geoff