HTML-Mason-ApacheHandler2

 view release on metacpan or  search on metacpan

diff/ApacheHandler.diff  view on Meta::CPAN

 
 use Class::Container;
 use base qw(Class::Container);
@@ -341,7 +345,7 @@
 }
 
 use constant
-    HAS_TABLE_API => $mod_perl::VERSION >= 1.99 || Apache::perl_hook('TableApi');
+    HAS_TABLE_API => $mod_perl::VERSION >= 1.99;
 
 my %AH_BY_CONFIG;
 sub make_ah
@@ -569,23 +573,27 @@
     my %params = @_;
 
     my %defaults;
-    $defaults{request_class}  = 'HTML::Mason::Request::ApacheHandler'
+    $defaults{request_class}  = 'HTML::Mason::Request::ApacheHandler2'
         unless exists $params{request};
-    $defaults{resolver_class} = 'HTML::Mason::Resolver::File::ApacheHandler'
+    $defaults{resolver_class} = 'HTML::Mason::Resolver::File::ApacheHandler2'
         unless exists $params{resolver};
 
     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
-    {
-	$defaults{comp_root} = $req->document_root;
+    if ( exists $allowed_params->{comp_root} ) {
+	if ( my $req = $r ) {
+	# DocumentRoot is only available inside requests
+	    $defaults{comp_root} = $req->document_root;
+	} else {
+	    $defaults{comp_root} =
+		Apache->server->dir_config( '_MasonDefaultDocumentRoot' );
+	}
     }
 
     if (exists $allowed_params->{data_dir} and not exists $params{data_dir})
     {
 	# constructs path to <server root>/mason
-	my $def = $defaults{data_dir} = Apache->server_root_relative('mason');
+	my $def = $defaults{data_dir} = Apache->server->server_root_relative('mason');
 	param_error "Default data_dir (MasonDataDir) '$def' must be an absolute path"
 	    unless File::Spec->file_name_is_absolute($def);
 	  
@@ -624,7 +632,7 @@
     unless ( $self->interp->resolver->can('apache_request_to_comp_path') )
     {
 	error "The resolver class your Interp object uses does not implement " .
-              "the 'apache_request_to_comp_path' method.  This means that ApacheHandler " .
+              "the 'apache_request_to_comp_path' method.  This means that ApacheHandler2 " .
               "cannot resolve requests.  Are you using a handler.pl file created ".
 	      "before version 1.10?  Please see the handler.pl sample " .
               "that comes with the latest version of Mason.";
@@ -633,7 +641,9 @@
     # If we're running as superuser, change file ownership to http user & group
     if (!($> || $<) && $self->interp->files_written)
     {
-	chown Apache->server->uid, Apache->server->gid, $self->interp->files_written
+	chown getpwnam( Apache->server->dir_config( '_MasonUser' ) ),
+	getgrnam( Apache->server->dir_config( '_MasonGroup' ) ),
+	$self->interp->files_written
 	    or system_error( "Can't change ownership of files written by interp object: $!\n" );
     }
 
@@ -684,8 +694,10 @@
 	    }
 
 	    return ["<center><h2>" . $self->apache_status_title . "</h2></center>" ,
-		    $self->status_as_html(apache_req => $r),
-		    $self->interp->status_as_html(ah => $self, apache_req => $r)];
+		    $self->status_as_html
+		    (apache_req => $r),
+		    $self->interp->status_as_html
+		    (ah => $self, $r) ];
 	};
 	local $^W = 0; # to avoid subroutine redefined warnings
 	Apache::Status->menu_item($status_name, $self->apache_status_title, $statsub);
@@ -700,7 +712,7 @@
 	if $interp->compiler->can('add_allowed_globals');
 }
 
-# Generate HTML that describes ApacheHandler's current status.
+# Generate HTML that describes ApacheHandler2's current status.
 # This is used in things like Apache::Status reports.
 
 sub status_as_html {
@@ -709,7 +721,7 @@
     # Should I be scared about this?  =)
 
     my $comp_source = <<'EOF';
-<h3>ApacheHandler properties:</h3>
+<h3>ApacheHandler2 properties:</h3>
 <blockquote>
  <tt>
 <table width="75%">
@@ -762,7 +774,7 @@
 </blockquote>
 
 <%args>
- $ah       # The ApacheHandler we'll elucidate
+ $ah       # The ApacheHandler2 we'll elucidate
  %valid    # Contains default values for member data
 </%args>
 EOF
@@ -807,7 +819,7 @@
     # use multiple variables to avoid this, which is annoying.
     my $r =
         $r_sub->( $self->args_method eq 'mod_perl' ?
-                  Apache::Request->instance( $_[0] ) :
+                  Apache::Request->new( $_[0] ) :
                   $_[0]
                 );
 
@@ -826,7 +838,7 @@
 
     if ($is_dir) {
 	if ($self->decline_dirs) {
-	    return DECLINED;
+	    return Apache::DECLINED;



( run in 0.762 second using v1.01-cache-2.11-cpan-5511b514fd6 )