How do I get the server to return my new object instead of a generic Apache object. Or, how do I get the server to return my object blessed as an Apache object, instead of returning a generic Apache::Request object?
I think the short answer is, you can't/don't. No matter how hard you try, handler() will always receive a vanilla Apache object
So the next best thing would be to always start out your handlers like so:
sub handler {
my $r = shift;
my $my_r = My::Apache::Request->new($r);
# do interesting things with $my_r
}
Or perhaps you can create something like the Apache->instance() method, and do something like:
# somewhere in your code...
my $r = My::Apache::Request->instance;
# in My::Apache::Request;
package My::Apache::Request;
use base qw(Apache::Singleton); # or something like it
sub _new_instance {
my $class = shift;
return $class->new(r => Apache::Request->instance);
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|