Re: Apache2
Dave Rolsky <[email protected]>
| Newsgroups | gmane.comp.web.mason.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 27 Jul 2004, John Williams wrote:
> On Tue, 27 Jul 2004, Dave Rolsky wrote:
> > if ( $mod_perl::VERSION >= 1.99 ) {
> > ...
> > } else {
> > ...
> > }
> >
> > The reason I dislike that is the two blocks of the branch generally are
> > doing the same thing, but they invoke slightly different methods or
> > classes to do what they want.
>
> I don't think it's too bad. There are already 3 mod_per::VERSION checks
> in ApacheHandler.pm (1 if, 2 ?:). I'm adding 6 more so far.
I don't like the 3 that are there is the problem ;)
> 1 big if is unavoidable to conditionally require the Apache module or the
> corresponding Apache2 modules.
That's fine.
> There are 3 places where I avoid calling send_http_headers, but all of
> them add the version check on to existing conditionals, so it is
> "if (something and version)" and no else.
that's better.
> Finally 2 in ?: style, which are kinda ugly. Suggestions for better style
> appreciated. This one avoids Apache->request:
>
> @@ -581,7 +596,7 @@
> my $allowed_params = $class->allowed_params(%defaults, %params);
>
> if ( exists $allowed_params->{comp_root} and
> - my $req = $r || Apache->request ) # DocumentRoot is only available inside requests
> + my $req = $r || ($mod_perl::VERSION < 1.99 ? Apache->request : undef) ) # DocumentRoot is only available inside requests
> {
> $defaults{comp_root} = $req->document_root;
> }
>
> And this one avoids Apache::Request->instance. The code here is already
> ugly, but the comments say there is a good reason for it. I could avoid
> this by doing:
> *Apache::Request::instance = \&Apache::Request::new;
> as recommended by the libapreq2 docs
> <http://search.cpan.org/~joesuf/libapreq2-2.03_04-dev/glue/perl/xsbuilder/Apache/Request/Request_pod#instance>.
>
> @@ -884,8 +901,10 @@
> # use multiple variables to avoid this, which is annoying.
> return
> $r_sub->( $self->args_method eq 'mod_perl' ?
> - Apache::Request->instance( $_[0] ) :
> - $_[0]
> + ($mod_perl::VERSION >= 1.99 ?
> + Apache::Request->new( $_[0] ) :
> + Apache::Request->instance( $_[0] ) )
> + : $_[0]
> );
> }
How about setting an $APREQ_CONSTRUCTOR "constant" earlier, and using
that?
-dave
/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click