angie ahl wrote:
> Hi guys
> 
> I'm having a pickle with trying to importing Apache:
> 
> I'm following the example in the Mod Perl Cookbook (v1) and looked at
> the code samples from the book online.
> 
> httpd.conf has this:

that's all ok.

> package mymod::hook;
> 
> use strict;
> use warnings;
> 
> use Apache::Constants qw(:common);

um, there's no Apache::Constants in mp2 :)  I wouldn't suggest using
Apache2::compat with method handlers though, but for no good reason - I
don't know that it _doesn't_ work, only that it adds a layer of complexity
that may be clouding the issue.

> sub handler {

that needs to be

  sub handler : method {

>       my $r = mymod::Apache->new(shift);
> 
>       $r->content_type('text/html'); # do output of header
>       
>       print $r->uri;
>       return Apache::OK;

Apache2::Const::OK with RC5

> #!/usr/bin/perl

that's an odd thing to have in a handler

> package mymod::Apache;
> 
> use Apache;

there's no Apache.pm in mp2

> 
> use DynaLoader;
> 
> use strict;
> 
> our @ISA = qw(DynaLoader Apache);

that should be Apache2::RequestRec

> 
> sub new {
> 
>   my ($class, $r) = @_;
> 
>   $r ||= Apache->request;

beware of that idiom in mp2 - it expect the request to be global, which
requires the proper httpd.conf switches.  just pass $r instead.

> 
>   return bless { r => $r }, $class;
> }
> 1;
> ________________________
> 
> 
> I get an error stating "Can't locate auto/mymod/Apache/content_typ.al in @INC"

since there's no Apache class in mp2 the autoloader can't find what it
needs. the mentioned adjustments should help.

> 
> Any idea what I'm missing? Is this another one of those things that's
> changed in MP2 ?

of course :)  but the underlying functionality is still there, and I'm sure
you can find stuff on method handlers in the perl.apache.org docs.

--Geoff

Reply via email to