peter wrote:
I tried what you suggested, but I still have the same problem.

The hend of the httpd.conf file contains:

NameVirtualHost *:80

PerlRequire "/etc/httpd/conf/startup.pl"
Include "/etc/httpd/conf/siteA"
Include "/etc/httpd/conf/siteB"
Include "/etc/httpd/conf/siteC"

and /etc/httpd/conf/startup.pl contains

#! /usr/bin/perl

$ModPerl::RegistryCooker::NameWithVirtualHost = 1;

And I restarted the httpd daemon.

Ah, sorry, actually $ModPerl::RegistryCooker::NameWithVirtualHost is 1 by default. It doesn't work because ModPerl::Registry (I assume that this is the class that you are using, since you didn't tell otherwise) uses a different method to convert the location of the script into a package namespace:


  package ModPerl::Registry;
  ...
  my %aliases = (
  ...
      namespace_from  => 'namespace_from_filename',
  ...

So it uses a full path to the script.

So what you want to do is to subclass ModPerl::Registry and have the subclass use the 'namespace_from_uri' method instead:

  #file:ModPerl/RegistryURI.pm
  #-------------------------------
  package ModPerl::RegistryURI;

  use strict;
  use warnings FATAL => 'all';

our $VERSION = '0.01';

use base qw(ModPerl::Registry);

  sub handler : method {
      my $class = (@_ >= 2) ? shift : __PACKAGE__;
      my $r = shift;
      return $class->new($r)->default_handler();
  }

  # a funky way to say:
  # *namespace_from  = \&ModPerl::RegistryCooker::namespace_from_uri;
  my %aliases = (
      namespace_from => 'ModPerl::RegistryCooker::namespace_from_uri',
  );
  __PACKAGE__->install_aliases(\%aliases);

  1;
  __END__

Now configure your server to use this new handler. For example:

  Alias /perl /path/to/perl/scripts
  <Location /perl>
     SetHandler perl-script
     PerlResponseHandler ModPerl::RegistryURI
     Options +ExecCGI
     #PerlOptions +ParseHeaders
  </Location>

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html



Reply via email to