<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">=pod

Message-ID:  &lt;199703312213.RAA25121@postman.osf.org&gt;
Date:         Mon, 31 Mar 1997 17:13:41 -0500
Reply-To: Discussion about the Apache ModPerl Module
              &lt;MODPERL@LISTPROC.ITRIBE.NET&gt;
Sender: Discussion about the Apache ModPerl Module
              &lt;MODPERL@LISTPROC.ITRIBE.NET&gt;
From: Doug MacEachern &lt;dougm@OPENGROUP.ORG&gt;
Subject:      Re: inheritance in Apache::Registry?
Comments: To: Brian Slesinsky &lt;bslesins@hotwired.com&gt;
To: MODPERL@LISTPROC.ITRIBE.NET
In-Reply-To:  Your message of "Mon, 31 Mar 1997 11:59:49 EST." 
              &lt;Pine.SOL.3.96.970331101839.24245A-100000@gossip.hotwired.com&gt;
X-UIDL: f0f4c4d1efcd7a44829843db9cf578d2

Brian Slesinsky &lt;bslesins@hotwired.com&gt; wrote:

&gt;
&gt; On Mon, 31 Mar 1997, Doug MacEachern wrote:
&gt;
&gt; &gt; I don't think you want to use Apache::Registry for this, the handler
&gt; &gt; class names are created on the fly, escaping the uri name until it's a
&gt; &gt; valid perl package name.  Your script moves, the class name changes.
&gt;
&gt; This doesn't really bother me.  Classes that are within htdocs probably
&gt; shouldn't be called from outside Apache anyway, so I don't need
&gt; to know their names.
&gt;
&gt; &gt; We could call Perl*Handlers as methods.
&gt;
&gt; Hmm, that means I have to mess with the Apache config, rather than just
&gt; creating a new file.
&gt;
&gt; So I tried making the changes myself, and it works, mostly.  Here are the
&gt; changes:
&gt;
[...]
&gt;
&gt; This works fine except that for some reason @ISA doesn't get used to look
&gt; up the initial call to handler().  I had to add this line to my script:
&gt;
&gt;    sub handler { $_[0]-&gt;SUPER::handler; }
&gt;
&gt; Of course, there's a lot of duplicated code that should really be in one
&gt; place.  Also, it would be nice if I could use both types of files in the
&gt; same directory, depending on whether the file extension is .pl or .pm.
&gt; But I can live with what I have.

okay, I think I have a better picture of what you want to do.  Look at
the example script I have below (using un-modified Apache::Registry).
It prints:

MyBase HEADER&lt;hr&gt;
&lt;p&gt;This is some text&lt;p&gt;
&lt;hr&gt;MyBase FOOTER

the uri is /perl/apache.pl, as you say, we don't care about our own
class name in this case, but we do setup the interitance tree.  In
this example we inherit from the `MyBase' package, which could also be
pulled in as a module.  The base class new(), header() and footer()
methods are inherited, but we implement our own body() method.  If
this is not what you are trying to do, please explain in greater
detail, example, etc.

-Doug

=cut 

use 5.004;
use CGI ();
use strict;
use vars qw(@ISA);
@ISA = qw(MyBase);

my $class = __PACKAGE__;

my $page = $class-&gt;new;
my $q = CGI-&gt;new;

print $q-&gt;header, map { $page-&gt;$_() } qw(header body footer);

sub body {
    my($self) = @_;
    return "&lt;p&gt;This is some text&lt;p&gt;\n";
}

package MyBase;

sub new {
    my($class) = @_;
    bless {}, $class;
}

sub footer {
    "&lt;hr&gt;MyBase FOOTER\n";
}

sub header {
    "MyBase HEADER&lt;hr&gt;\n";
}

sub body {
      "MyBase BODY\n";
}

</pre></body></html>