On Tuesday 23 March 2004 12:55 am, Beau E. Cox wrote:
> On Tuesday 23 March 2004 12:04 am, Beau E. Cox wrote:
> > -------------8<---------- Start Bug Report ------------8<----------
> > 1. Problem Description:
> >
> >   Using latest (CVS) Apache2, mod_perl 2, libapreq2:
> >
> >   t/modules/apache_status fails
> >
> >   console log:
> >
> > [...]
> >
> >   error_log:
> >
> > [...]
> > [Mon Mar 22 23:52:14 2004] [error] failed to resolve handler
> > `Apache::Status' [Mon Mar 22 23:52:14 2004] [error] [client 127.0.0.1]
> > Argument "2.03-dev" isn't numeric in numeric ge (>=)
> > at /home/test/src/modperl2/modperl-2.0/blib/lib/Apache/Status.pm line 35.
> > \nCompilation failed in require at (eval 95) line 3.\n
> > [...]
>
> I should have seen this, but my libapreq2 version is NOT numeric -
> '2.03-dev', so compile error.
>
> Also seems to be an if/else problem later. This patch works for me:
>
> diff -Nau unpatched/Status.pm patched/Status.pm
> --- unpatched/Status.pm       2004-03-23 00:48:50.212799704 -1000
> +++ patched/Status.pm 2004-03-23 00:42:25.498285200 -1000
> @@ -32,7 +32,8 @@
>  our $newQ;
>
>  if (eval { require Apache::Request }) {
> -    if ($Apache::Request::VERSION >= 2) {
> +    my ( $ver ) = $Apache::Request::VERSION =~ /(\d+[\.]*\d*)/;
> +    if ($ver >= 2) {
>          $newQ ||= sub { Apache::Request->new(@_) };
>      }
>  }
> @@ -60,7 +61,7 @@
>          $newQ ||= sub { CGI->new };
>      }
>  }
> -else {
> +if (!$newQ) {
>      die "Need CGI.pm or Apache::Request to operate";
>  }

Still did't work. Startup fails like so:

Starting httpd[Tue Mar 23 01:03:34 2004] [error] Subroutine 
Apache::Status::status_mason0001 redefined 
at 
/home/test/perl/5.8.3-ithread/lib/site_perl/5.8.3/i686-linux-thread-multi/Apache/Status.pm
 
line 140.\nCompilation failed in require 
at /home/test/httpd/conf/wm-startup2.pl line 41.\nBEGIN failed--compilation 
aborted at /home/test/httpd/conf/wm-startup2.pl line 41.\nCompilation failed 
in require at (eval 2) line 1.\n
[Tue Mar 23 01:03:34 2004] [error] Can't load Perl 
file: /home/test/httpd/conf/wm-startup2.pl for server cathy.beaucox.com:0, 
exiting...

wm-startup2.pl ( line 41 marked with > ):

###################################################
#       Apache2/mod_perl2/mason startup script
#       Beau E. Cox
#       Feb 25, 2004
#
#       file:startup2.pl
###################################################

use Apache2 ();
use lib ( $ENV{MOD_PERL_INC} );

use Apache::Request ();
use Apache::Cookie ();
use CGI ();
use CGI::Cookie ();

use ModPerl::Util (); #for CORE::GLOBAL::exit

use Apache::RequestRec ();
use Apache::RequestIO ();
use Apache::RequestUtil ();

use Apache::Server ();
use Apache::ServerUtil ();
use Apache::Connection ();
use Apache::Log ();
use Apache::URI ();

use Apache::Session ();

use APR::Table ();

use ModPerl::Registry ();

use Apache::Const -compile => ':common';
use APR::Const -compile => ':common';
use ModPerl::Const -compile => ':common';

use Apache::DBI ();

>use MyApache::Apache2Handler ();

1;

MyApache::Apache2Handler:

#!/usr/bin/perl
#--------------------------------------------------
#
#       Mason Apache2Handler.pm
#
#       Built for multiple sites, mutiple component
#       roots.
#
#       Feb 25, 2004
#       Beau E. Cox
#       <[EMAIL PROTECTED]><http://beaucox.com>
#
#--------------------------------------------------

package MyApache::Apache2Handler;

use strict;
use warnings;

use Apache2 ();
use lib ( $ENV{MOD_PERL_INC} );

use Apache::Request ();
use Apache::Cookie ();
use CGI ();
use CGI::Cookie ();

our %ah = ();

#       Mason w/Apache support
use MasonX::Apache2Handler;

#       Modules my components will use
{
    package HTML::Mason::Commands;
        
    use Apache::Const -compile => ':common';
    use APR::Const -compile => ':common';
    use ModPerl::Const -compile => ':common';

    use Apache::Session;
    use MasonX::Request::WithApache2Session;

    use vars qw(%session);
    use Apache::Session::File 1.50;

    use DBI;
    use Data::Dumper;
    use Image::Magick;
    use Date::Format;
    use Net::IP::CMatch;
    use HTML::Lint;

}

setup_sites();

#       actual request handler
sub handler
{
    my ($r) = @_;

#   DON'T allow internal components (starting with '_')
    my $fn = $r->filename;
    if ($fn =~ m{.*/(.*)} && $1 && $1 =~ /^_/) {
        my $rip = $r->connection->remote_ip;
        $r->log_error ("attempt to access internal component: $fn remote ip: 
$rip\n");
        return Apache::NOT_FOUND;
    }

#   allow only text/xxx content type
    return -1 if $r->content_type && $r->content_type !~ m|^text/|i;

#   find site and handler: dispatch request
    my $site = $r->dir_config ('mason_site');

    unless( $site ) {
        $r->log_error ("no 'mason_site' specified\n");
        return Apache::NOT_FOUND;
    }
    unless( $ah{$site} ) {
        setup_sites( $r, $site );
        unless( $ah{$site} ) {
            $r->log_error ("no 'ah' found for 'mason_site' $site\n");
            return Apache::NOT_FOUND;
        }
    }

    my $status = $ah{$site}->handle_request( $r );

#   special error handling here (email, etc...)
    $status;
}

#   set up an ApacheHandler2 for each site
sub setup_sites
{
    my ( $r, $site ) = shift;
    my @asites = ();
    if( $site ) {
        push @asites, $site;
    } else {
        my $sites = $ENV{MASON_SITES};
        return unless $sites;
        @asites = split /:/, $sites;
    }
    for my $site( @asites ) {
        next if $ah{$site};
        my @args =
            (
             args_method                => "mod_perl",
             comp_root                  => $ENV{MASON_COMP_ROOT}."/$site",
             data_dir                   => $ENV{MASON_DATA_ROOT}."/$site",
             error_mode                 => 'output',
             request_class      =>'MasonX::Request::WithApache2Session',
             session_allow_invalid_id   => 'yes',
             session_cookie_name        => "beaucox-$site-cookie",
             session_cookie_domain      => '.beaucox.com',
             session_cookie_expires     => '+7d',
             session_class              => 'Apache::Session::MySQL',
             session_data_source        => "dbi:mysql:${site}_sessions",
             session_user_name          => 'mysql',
             session_password           => 'mysql',
             session_lock_data_source   => "dbi:mysql:${site}_sessions",
             session_lock_user_name     => 'mysql',
             session_lock_password      => 'mysql',
             session_use_cookie         => 'yes',
             );
        push @args, $r if $r;
        $ah{$site} = new MasonX::Apache2Handler( @args );
    }
}

1;                      

__END__


I'm stumped.

Picked up Status.pm from a download a few days ago:

-rw-r--r--  1 install users 22617 Mar  7 23:24 Status.pm

and it works OK now.

Aloha => Beau;


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to