[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: Re: method handlers
From:       "Jordan McLain" <jordan.mclain () gmail ! com>
Date:       2006-10-27 13:46:41
Message-ID: 5622edeb0610270646h8437c18n7415d3b61bf2b889 () mail ! gmail ! com
[Download RAW message or body]

Ahh, I see.  Great tip.  Thanks alot.

Jordan

On 10/27/06, John ORourke <john-modperl@o-rourke.org> wrote:
> Jordan McLain wrote:
>
> > just noticed...  in the actual code 'handler' is prototyped with ($$)
> >
> >
> >> sub handler {
> >>  my ($class, $r) = @_;
> >>
> >>  my $self = ... # something hashref-ish
> >
> >> I will end up writing another "new()" for use when not called directly
> >> from apache.  Is this bad style, since the method does not return the
> >> blessed ref to something, but instead calls methods directly with the
> >> blessed ref?
> >
>
> Personally I get Apache to call new() for me, so other code can use the
> class in the same way apache does:
>
> -----------------------------------------------
> in httpd.conf:
>
>     PerlModule My::HandlerModule
>
>        PerlResponseHandler My::HandlerModule->handler_method   # apache
> calls your new() method automatically I think
>        PerlFixupHandler My::HandlerModule->fixup_handler_method
> -----------------------------------------------
>
> Or even better, when I want a single instance of my handler module per
> apache process:
>
> -----------------------------------------------
> package My::HandlerModule;
>
> $My::HandlerModule::Persistent=My::HandlerModule->new();
>
> sub new { etc etc }
> sub handler_method { my ($self,$r)=@_;  etc etc }
> -----------------------------------------------
> in httpd.conf:
>
>     PerlResponseHandler $My::HandlerModule::Persistent->handler_method
> -----------------------------------------------
>
> hope this helps,
> John
>
>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic