perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip M. Gollucci" <pgollu...@p6m7g8.com>
Subject Re: [mp2] CGI.pm porting/co-existence questions
Date Sun, 07 Aug 2005 23:29:49 GMT
Thomas Hilbig wrote:
>>>Also, the mp2 User's Guide (section 10.9.1) says
>>>CGI.pm now takes $r as an argument to its new()
>>>function.  What benefit is this?  Is it required? 
>>
>>For the most part its optional.
>>You may need to look at PerlGlobalRequest
>>
> 
> http://perl.apache.org/docs/2.0/user/config/config.html#C_GlobalRequest_
> 
> I'm still confused why this is optional in CGI.pm. 
> Does it save some cycles by avoiding CGI.pm having to
> sniff around for the Apache requestor?
 From CGI.pm::new():

....
  if (ref($initializer[0])
       && (UNIVERSAL::isa($initializer[0],'Apache')
           ||
           UNIVERSAL::isa($initializer[0],'Apache2::RequestRec')
          )) {
     $self->r(shift @initializer);
   }
....
if ($MOD_PERL) {
     if ($MOD_PERL == 1) {
       $self->r(Apache->request) unless $self->r;
       my $r = $self->r;
       $r->register_cleanup(\&CGI::_reset_globals);
     }
     else {
       # XXX: once we have the new API
       # will do a real PerlOptions -SetupEnv check
       $self->r(Apache2::RequestUtil->request) unless $self->r;
       my $r = $self->r;
       $r->subprocess_env unless exists $ENV{REQUEST_METHOD};
       $r->pool->cleanup_register(\&CGI::_reset_globals);
     }
     undef $NPH;
}
....

After CGI->new() or CGI->new($r) is called from here on out internall it 
will just use $self->r whenver an Apache2::Request object is needed.
I'm not entirely sure it will say you speed passing or not passing it. 
The only benefit I see is that you could pass a subclassed version in.

Though I may be missing something.

HTH



-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com


Mime
View raw message