tosh has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to subclass Apache::AuthDBI by doing:
package MyAuthDBI; use base "Apache::AuthDBI"; 1;
Then in apache.conf
PerlModule MyAuthDBI <Location /test> AuthType Basic PerlAuthenHandler MyAuthDBI::authen ... </Location>
I'm getting the following error:

...failed to resolve handler `MyAuthDBI::authen': Can't locate MyAuthDBI/authen.pm in @INC...

Which kinda makes sense as an error message since the handler is declared MyAuthDBI::authen and not MyAuthDBI->authen and yet it works just fine if I allow Apache::AuthDBI to handle the Authen.

Is it non trivial to subclass Apache::AuthDBI? Am I doing something glaringly dumb?

Thanks again...

Tosh

Replies are listed 'Best First'.
Re: Subclassing Apache::AuthDBI
by tosh (Scribe) on Dec 08, 2009 at 22:14 UTC
    Yay to MidLifeXis for pointing out the problem.

    When MyAuthDBI::authen is called then PERL looks to that specific object for the function rather than traversing up the parent tree. MyAuthDBI->authen would call the function but the original Apache::AuthDBI::authen expects $r as the first argument and not $self and so a new set of problems arises.

    So the easy solution to this problem is:
    package MyAuthDBI; use base "Apache::AuthDBI"; sub authen { my ($r) = @_; Apache::AuthDBI::authen($r); } 1;
    Big props out to MidLifeXis for noticing this, thanks!