The things I'm trying to do seem a little more advanced than general mod_perl stuff, but nothing that should require delving into the C and XS code.

uh, right. you don't need to delve into C/XS. Whatever gave you that idea?

If you want to create objects to handle generating content, just create a handler that instantiates an object:

package My::Handler; sub handler { my $r = shift; # translate from URL to package name, and the "action" # that you want to perform my($pkg, $action) = figure_out_package_name($r->uri); # instantiate, and call the appropriate handler my $obj = $pkg->new(); $obj->dispatch($action); }

Meanwhile, if you still insist on subclassing Apache (which, I'm starting to think could be useful, but is still parallel to what you are trying to solve), you could just add a hook to do so in the dispatch() method above:

sub dispatch { my($self, $action) = @_; my $my_r = My::Apache::Request->new(Apache->request); $self->do_the_appropriate_thing($action, $my_r); }

Then when you write code for the actual objects that handle the request, you can safely assume that you will get the appropriate request object. No?


In reply to Re^5: Subclassing Apache::Request? by lestrrat
in thread Subclassing Apache::Request? by tadamec

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.