perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug MacEachern <do...@pobox.com>
Subject Re: ?? Sub-Classing Apache::Request
Date Wed, 01 Mar 2000 07:43:38 GMT
On Thu, 24 Feb 2000, Clifford Lang wrote:

> mod_perl 1.21, Apache 1.3.9
> 
> This may be a general perl question, but I know this group has solved this
> if it can be solved.
> 
> I want to sub-class Apache::Request to add some custom fuctionality to
> Apache::Request->new(), and add custom functions/methods to the returned
> object.
> 
> My problem is I don't (can't?) get the "param" method to return any data
> from my object.  Apache::Request->new($r) works as expected.
> 
> Here is my striped down basic package - What am I missing?  Can I do what I
> want?
> 
> package My::UploadOBJ;
> 
> use strict;
> use Apache::Request;
> use vars qw($VERSION @ISA);
> @ISA=qw(Apache::Request);
> 
> $VERSION = '0.01';
> 
> sub new {
>   my $class = shift;
>   my $r = shift;
>   return $class->SUPER::new($r), $class;
> }

see chapter 7 of wrapmod, subclassing Apache::Request is done the same
way:

=head1 Subclassing the Apache Class
...
To be successful, the new class must add I<Apache> (or another
I<Apache> subclass) to its C<@ISA> array.  In addition, the subclass's
I<new()> method must return a blessed hash reference which contains
either an I<r> or I<_r> key.  This key must point to a bona fide
I<Apache> object.
...
 sub new {
     my($class, $r) = @_;
     $r ||= Apache->request;
     return bless {
 	'_r' => $r,
 	'data' => [],
     }, $class;
 }


Mime
View raw message