Hi Lincoln,
Nick Tonkin is working on the patch to make CGI::Cookie work properly under
modperl 2.0 in pre-response handlers, and the issue of providing the API for
passing $r to CGI.pm and CGI::Cookie has been raised again.
I'm proposing the following API:
- CGI.pm:
CGI->r($r); # for non-OO API
or
my $q = CGI->new;
$q->r($r); # for OO API
- CGI::Cookie
CGI::Cookie::r($r);
or something like that. Though we have to make into an account that CGI.pm
might be used in sub-requests, so we should probably make sure that we aren't
using the wrong global $r.
and this is the implementation for CGI::Cookie (we need a similar one for
CGI.pm). I have also suggested to abstract all the mp functionality in a
separate module e.g., CGI/MP.pm, so we don't have to duplicate and maintain
several copies of the same code. Loading CGI.pm in CGI::Cookie sounds like a
bad idea if CGI is not already used elsewhere, because of the bloat.
package CGI::Cookie;
...
use vars qw($gr); # global $r
# get/set
sub r {
$gr = shift if @_;
return $gr || Apache->request;
}
sub new {
...
if ($MOD_PERL) {
r()->pool->cleanup_register(\&CGI::Cookie::_reset_globals);
}
}
sub _reset_globals { initialize_globals(); }
sub initialize_globals {
$gr = undef;
}
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@... http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com