stas        2002/12/29 02:08:08

  Modified:    ModPerl-Registry/lib/ModPerl RegistryCooker.pm
                        RegistryLoader.pm
  Log:
  support the NameWithVirtualHost setting in namespace_from_uri() as in 1.0
  (would be nice to add a test, but I'm not sure how to do that)
  
  Revision  Changes    Path
  1.26      +12 -0     modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm
  
  Index: RegistryCooker.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryCooker.pm,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- RegistryCooker.pm 28 Dec 2002 07:13:26 -0000      1.25
  +++ RegistryCooker.pm 29 Dec 2002 10:08:08 -0000      1.26
  @@ -85,6 +85,12 @@
   
   
   #########################################################################
  +
  +unless (defined $ModPerl::RegistryCooker::NameWithVirtualHost) {
  +    $ModPerl::RegistryCooker::NameWithVirtualHost = 1;
  +}
  +
  +#########################################################################
   # func: new
   # dflt: new
   # args: $class - class to bless into
  @@ -310,6 +316,12 @@
       my $script_name = $path_info && $self->[URI] =~ /$path_info$/ ?
        substr($self->[URI], 0, length($self->[URI]) - length($path_info)) :
        $self->[URI];
  +
  +    if ($ModPerl::RegistryCooker::NameWithVirtualHost && 
  +        $self->[REQ]->server->is_virtual) {
  +        my $name = $self->[REQ]->get_server_name;
  +        $script_name = join "", $name, $script_name if $name;
  +    }
   
       $script_name =~ s:/+$:/__INDEX__:;
   
  
  
  
  1.7       +5 -1      modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryLoader.pm
  
  Index: RegistryLoader.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/lib/ModPerl/RegistryLoader.pm,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RegistryLoader.pm 29 Dec 2002 09:18:50 -0000      1.6
  +++ RegistryLoader.pm 29 Dec 2002 10:08:08 -0000      1.7
  @@ -21,7 +21,7 @@
   }
   
   sub handler {
  -    my($self, $uri, $filename) = @_;
  +    my($self, $uri, $filename, $virthost) = @_;
   
       # set the inheritance rules at run time
       @ISA = $self->{package};
  @@ -73,6 +73,8 @@
           package  => $self->{package},
       } => ref($self) || $self;
   
  +    $rl->{virthost} = $virthost if defined $virthost;
  +
       # can't call SUPER::handler here, because it usually calls new()
       # and then the ModPerlRegistryLoader::new() will get called,
       # instead of the super class' new, so we implement the super
  @@ -86,6 +88,7 @@
   # when when finfo() and slurp_filename() are ported to 2.0 and
   # RegistryCooker is starting to use them
   
  +sub get_server_name { return $_[0]->{virthost} if exists $_[0]->{virthost} }
   sub filename { shift->{filename} }
   sub status { Apache::HTTP_OK }
   sub my_finfo    { shift->{filename} }
  @@ -95,6 +98,7 @@
   sub log_error { shift; die @_ if $@; warn @_; }
   sub run { return Apache::OK } # don't run the script
   sub server { shift }
  +sub is_virtual { exists shift->{virthost} }
   
   # the preloaded file needs to be precompiled into the package
   # specified by the 'package' attribute, not RegistryLoader
  
  
  


Reply via email to