perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbek...@hyperreal.org
Subject cvs commit: modperl/lib/Apache RegistryLoader.pm
Date Tue, 05 Oct 1999 21:33:28 GMT
sbekman     99/10/05 14:33:19

  Modified:    lib/Apache RegistryLoader.pm
  Log:
  Rewrote the handler() to report and handle all the possible erroneous
  conditions inside the handler subroutine.
  
  Revision  Changes    Path
  1.16      +41 -27    modperl/lib/Apache/RegistryLoader.pm
  
  Index: RegistryLoader.pm
  ===================================================================
  RCS file: /export/home/cvs/modperl/lib/Apache/RegistryLoader.pm,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- RegistryLoader.pm	1999/03/16 08:55:06	1.15
  +++ RegistryLoader.pm	1999/10/05 21:32:51	1.16
  @@ -5,9 +5,9 @@
   use Apache::Registry ();
   use Apache::Constants qw(OPT_EXECCGI);
   @Apache::RegistryLoader::ISA = qw(Apache::Registry);
  -$Apache::RegistryLoader::VERSION = '1.90';
  +$Apache::RegistryLoader::VERSION = '1.91';
   
  -sub new { 
  +sub new {
       my $class = shift;
       bless {@_} => $class;
   }
  @@ -15,31 +15,41 @@
   sub handler {
       my($self, $uri, $filename) = @_;
   
  -    unless($filename) {
  -	if(my $func = $self->{trans}) {
  -	    no strict 'refs';
  -	    $filename = &{$func}($uri);
  -        } else {
  -
  -      # warn user if translate process fails,
  -          warn "RegistryLoader: Cannot translate the URI 
  -	$uri
  -	into a real path to the filename. You have to pass URI 
  -	and not a filesystem path (e.g. /perl/test.pl vs. 
  -	/home/httpd/perl/test.pl). Please refer to the 
  -	manpage for more information or use the complete method's 
  -	call like: \$r->handler(URI,filename);\n";
  -        }
  +    Apache::warn(__PACKAGE__.qq{ failed, reason: uri is a required parameter}),
  +	return
  +	  unless defined $uri and $uri;
  +
  +    if ($filename) {
  +      Apache::warn(__PACKAGE__.qq{: Cannot find a filename [$filename]}),
  +	  return
  +	    unless -e $filename;
  +    } else {
  +
  +      # try to translate URI->filename
  +      if (my $func = $self->{trans}) {
  +	no strict 'refs';
  +	$filename = &{$func}($uri);
  +	Apache::warn(__PACKAGE__.
  +		     qq{: Translation of uri [$uri] to filename failed [tried: $filename]}),
  +		       return
  +			 unless -e $filename;
  +      } else {
  +	# try to guess
  +	(my $guess = $uri) =~ s,^/,,;
  +	$filename = Apache->server_root_relative($guess);
  +	Apache::warn(__PACKAGE__.
  +		     qq{: No 'trans' sub was passed: tried to guess the filename [tried: $filename],
but failed, for uri [$uri]}),
  +		       return
  +			 unless -e $filename;
  +      }
       }
   
  -    #warn "RegistryLoader: uri=$uri, filename=$filename\n";
  +    # warn "*** RegistryLoader: uri=$uri, filename=$filename\n";
   
  -    (my $guess = $uri) =~ s,^/,,;
  -
       my $r = bless {
  -	uri => $uri,
  -	filename => Apache->server_root_relative($filename || $guess),
  -    } => ref($self) || $self;
  +		   uri => $uri,
  +		   filename => $filename,
  +		  } => ref($self) || $self;
   
       $r->SUPER::handler;
   }
  @@ -98,9 +108,9 @@
   =head1 DESCRIPTION
   
   This modules allows compilation of B<Apache::Registry> scripts at
  -server startup.  The script's handler routine is compiled by the 
  -parent server, of which children get a copy.  
  -The Apache::RegistryLoader C<handler> method takes arguments of C<uri> 
  +server startup.  The script's handler routine is compiled by the
  +parent server, of which children get a copy.  The
  +B<Apache::RegistryLoader> C<handler> method takes arguments of C<uri>
   and the C<filename>.  URI to filename translation normally doesn't
   happen until HTTP request time, so we're forced to roll our own
   translation.
  @@ -151,10 +161,14 @@
        }
    }
   
  -=head1 AUTHOR
  +=head1 AUTHORS
   
   Doug MacEachern
   
  +Stas Bekman (Rewrote the handler() to report and handle all the possible
  +erroneous conditions)
  +
   =head1 SEE ALSO
   
   Apache::Registry(3), Apache(3), mod_perl(3)
  +
  
  
  

Mime
View raw message