Re: [MP2] Import Apache with @ISA

[prev] [thread] [next] [Date index for 2005/04/20]

From: Geoffrey Young
Subject: Re: [MP2] Import Apache with @ISA
Date: 17:38 on 20 Apr 2005

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

(message missing)

[MP2] Import Apache with @ISA
angie ahl 17:31 on 20 Apr 2005

Re: [MP2] Import Apache with @ISA
Geoffrey Young 17:38 on 20 Apr 2005

RC5 really broke some stuff
Foo Ji-Haw 02:22 on 21 Apr 2005

Re: RC5 really broke some stuff
jonathan vanasco 03:07 on 21 Apr 2005

Re: RC5 really broke some stuff
Foo Ji-Haw 04:04 on 21 Apr 2005

Re: RC5 really broke some stuff
Michael J Schout 04:10 on 21 Apr 2005

Re: RC5 really broke some stuff
Randy Kobes 04:11 on 21 Apr 2005

Re: RC5 really broke some stuff
Tom Schindl 08:01 on 22 Apr 2005

Re: RC5 really broke some stuff
Philip M. Gollucci 08:05 on 22 Apr 2005

Re: RC5 really broke some stuff
Adam Kennedy 05:34 on 21 Apr 2005

Re: RC5 really broke some stuff
jonathan vanasco 04:50 on 21 Apr 2005

Re: RC5 really broke some stuff
Perrin Harkins 05:14 on 21 Apr 2005

Re: RC5 really broke some stuff
Foo Ji-Haw 06:17 on 21 Apr 2005

Re: RC5 really broke some stuff
Carl Johnstone 10:02 on 22 Apr 2005

Re: RC5 really broke some stuff
Jie Gao 02:21 on 23 Apr 2005

Re: RC5 really broke some stuff
Fred Moyer 02:42 on 23 Apr 2005

Re: RC5 really broke some stuff
Stas Bekman 04:59 on 23 Apr 2005

Re: RC5 really broke some stuff
Perrin Harkins 16:55 on 24 Apr 2005

Re: RC5 really broke some stuff
Philip M. Gollucci 06:26 on 21 Apr 2005

Re: RC5 really broke some stuff
Foo Ji-Haw 06:38 on 21 Apr 2005

Re: RC5 really broke some stuff
Philip M. Gollucci 07:09 on 21 Apr 2005

Re: RC5 really broke some stuff
jonathan vanasco 12:54 on 21 Apr 2005

Re: RC5 really broke some stuff
Geoffrey Young 11:30 on 21 Apr 2005

Re: RC5 really broke some stuff
John D Groenveld 18:05 on 21 Apr 2005

Re: RC5 really broke some stuff
Adam Kennedy 06:05 on 22 Apr 2005

Re: RC5 really broke some stuff
Philip M. Gollucci 06:26 on 22 Apr 2005

Re: RC5 really broke some stuff
Adam Kennedy 06:28 on 22 Apr 2005

Re: RC5 really broke some stuff
Jonathan Vanasco 16:03 on 25 Apr 2005

Generated at 09:30 on 27 Apr 2005 by mariachi v0.52