You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Clifford Lang <Cl...@GTSI.com> on 2000/02/24 15:34:39 UTC
?? Sub-Classing Apache::Request
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;
}
1;
__END__
##################################
Thanks, Cliff
Re: ?? Sub-Classing Apache::Request
Posted by Doug MacEachern <do...@pobox.com>.
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;
}