[prev in list] [next in list] [prev in thread] [next in thread]
List: mason-cvs
Subject: [Mason-checkins] CVS: mason/dist/lib/HTML/Mason ApacheHandler.pm,1.323,1.324
From: John Williams <sharkey3 () users ! sourceforge ! net>
Date: 2005-05-29 1:55:11
Message-ID: E1DcD1D-0005Mr-5m () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]
Update of /cvsroot/mason/mason/dist/lib/HTML/Mason
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19415/lib/HTML/Mason
Modified Files:
ApacheHandler.pm
Log Message:
mod_perl2 renaming: need to check both mod_perl2::VERSION and mod_perl::VERSION
CGI-3.08 is required for mod_perl2
Apache::Request is now Apache2::Request
Index: ApacheHandler.pm
===================================================================
RCS file: /cvsroot/mason/mason/dist/lib/HTML/Mason/ApacheHandler.pm,v
retrieving revision 1.323
retrieving revision 1.324
diff -u -r1.323 -r1.324
--- ApacheHandler.pm 4 May 2005 01:42:39 -0000 1.323
+++ ApacheHandler.pm 29 May 2005 01:55:08 -0000 1.324
@@ -5,8 +5,6 @@
# under the same terms as Perl itself.
use strict;
-# This is the version that introduced PerlAddVar
-use mod_perl 1.24;
#----------------------------------------------------------------------
#
@@ -14,6 +12,26 @@
#
package HTML::Mason::Request::ApacheHandler;
+# PerlAddVar was introduced in mod_perl-1.24
+# Support for 1.99 <= modperl < 2.00 was removed due to constantly changing APIs
+BEGIN
+{
+ eval { require mod_perl2 };
+ if ($@) {
+ # hmm, mod_perl < 2.00?
+ require mod_perl;
+ }
+ my $mpver = ($mod_perl2::VERSION || $mod_perl::VERSION);
+
+ # This is the version that introduced PerlAddVar
+ if ($mpver < 1.24) {
+ die "mod_perl VERSION >= 1.24 required";
+ }
+ if ($mpver >= 1.99 && $mpver < 2.00) {
+ die "mod_perl-1.99 is not supported; upgrade to 2.00";
+ }
+}
+
use HTML::Mason::Request;
use Class::Container;
use Params::Validate qw(BOOLEAN);
@@ -23,7 +41,7 @@
use HTML::Mason::Exceptions( abbr => [qw(param_error error)] );
-use constant APACHE2 => $mod_perl::VERSION >= 1.99;
+use constant APACHE2 => ($mod_perl2::VERSION || $mod_perl::VERSION) >= 2.00;
use constant OK => 0;
use constant DECLINED => -1;
use constant NOT_FOUND => 404;
@@ -193,7 +211,7 @@
use Params::Validate qw(:all);
Params::Validate::validation_options( on_fail => sub { param_error( join '', @_ ) } );
-use constant APACHE2 => $mod_perl::VERSION >= 1.99;
+use constant APACHE2 => ($mod_perl2::VERSION || $mod_perl::VERSION) >= 2.00;
use constant OK => 0;
use constant DECLINED => -1;
use constant NOT_FOUND => 404;
@@ -271,10 +289,15 @@
interp ) ]
);
+sub _get_apache_server
+{
+ return APACHE2 ? Apache2::ServerUtil->server() : Apache->server();
+}
+
my ($STARTED);
# The "if Apache->server" bit is a hack to let the make_params_pod.pl script work
-__PACKAGE__->_startup() if Apache->server;
+__PACKAGE__->_startup() if _get_apache_server;
sub _startup
{
my $pack = shift;
@@ -284,11 +307,17 @@
{
if ($args_method eq 'CGI')
{
- require CGI unless defined CGI->VERSION;
+ eval { require CGI unless defined CGI->VERSION; };
+ # mod_perl2 does not warn about this, so somebody should
+ if (APACHE2 && CGI->VERSION < 3.08) {
+ warn("CGI version 3.08 is required to support mod_perl2 API");
+ }
+ die $@ if $@;
}
elsif ($args_method eq 'mod_perl')
{
- require Apache::Request unless defined Apache::Request->VERSION;
+ my $apreq_module = APACHE2 ? 'Apache2::Request' : 'Apache::Request';
+ require $apreq_module unless defined $apreq_module->VERSION;
}
}
}
@@ -381,7 +410,7 @@
my $self = shift;
my $r = shift;
- my $config = $r ? $r->dir_config : Apache->server->dir_config;
+ my $config = $r ? $r->dir_config : _get_apache_server->dir_config;
# Get all params starting with 'Mason'
my %candidates;
@@ -500,12 +529,12 @@
{
if ($config)
{
- my $c = $r ? $r : Apache->server;
+ my $c = $r ? $r : _get_apache_server;
@val = $config->get($p);
}
else
{
- my $c = $r ? $r : Apache->server;
+ my $c = $r ? $r : _get_apache_server;
@val = $c->dir_config->get($p);
}
}
@@ -544,8 +573,8 @@
if (exists $allowed_params->{data_dir} and not exists $params{data_dir})
{
# constructs path to <server root>/mason
- if (UNIVERSAL::can('Apache::ServerUtil','server_root')) {
- $defaults{data_dir} = File::Spec->catdir(Apache::ServerUtil::server_root(),'mason');
+ if (UNIVERSAL::can('Apache2::ServerUtil','server_root')) {
+ $defaults{data_dir} = File::Spec->catdir(Apache2::ServerUtil::server_root(),'mason');
} else {
$defaults{data_dir} = Apache->server_root_relative('mason');
}
@@ -627,12 +656,13 @@
sub _initialize {
my ($self) = @_;
+ my $apreq_module = APACHE2 ? 'Apache2::Request' : 'Apache::Request';
if ($self->args_method eq 'mod_perl') {
- unless (defined Apache::Request->VERSION) {
- warn "Loading Apache::Request at runtime. You could " .
+ unless (defined $apreq_module->VERSION) {
+ warn "Loading $apreq_module at runtime. You could " .
"increase shared memory between Apache processes by ".
"preloading it in your httpd.conf or handler.pl file\n";
- require Apache::Request;
+ require $apreq_module;
}
} else {
unless (defined CGI->VERSION) {
@@ -861,7 +891,9 @@
$r_sub = $no_filter;
}
- my $instance_method = APACHE2 ? 'new' : 'instance';
+ my $apreq_instance = APACHE2
+ ? sub { Apache2::Request->new( $_[0] ) }
+ : sub { Apache::Request->instance( $_[0] ) };
# This gets the proper request object all in one fell swoop. We
# don't want to copy it because if we do something like assign an
@@ -870,7 +902,7 @@
# use multiple variables to avoid this, which is annoying.
return
$r_sub->( $self->args_method eq 'mod_perl' ?
- Apache::Request->$instance_method( $_[0] ) :
+ &$apreq_instance( $_[0] ) :
$_[0]
);
}
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
Mason-checkins mailing list
Mason-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-checkins
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic