Nicolas MONNET <[EMAIL PROTECTED]> sez:


> Apparently, the Apache::RegistryLoader man page states that you have to
> point a script by it's URI, or IOW, relative to the ServerRoot.
>
> But what happens when you have several virtual hosts? Isn't there a way to
> preload scripts based on their full path on the disk? Would it be possible
> to hack Apache::RegistryLoader so that it allows it? Or am I doomed?

The first argument given to Apache::RegistryLoader has to include the
virtual host.  But RegistryLoader won't be able to figure out where to find
the appropriate script on the filesystem.  So you can use the two-argument
form of handler() to help it find the actual file.  For example:

  $rl->handler('foo.bar.com/index.pl', '/usr/foo/public_html/index.pl');

After preloading a few dozen Registry scripts, you'll grow weary of the
two-argument form and start looking for shortcuts.  The shortcut is to
define your own function to turn a URI into a filename.  One you've done
this, you can use the one-argument form of handler().  Here's an example I
lifted from my own startup.pl:

  # preload Apache::Registry scripts
  use Apache::RegistryLoader ();
  my $rl = Apache::RegistryLoader->new(trans => sub {
    my $uri = shift;
    $uri =~ s/^foo.bar.com//;  # remove vhost from start
    return "/usr/foo/public_html$uri";  # return full path to script
  });
  $rl->handler('foo.bar.com/index.pl');
  $rl->handler('foo.bar.com/article/index.pl');
  $rl->handler('foo.bar.com/admin/delete.pl');
  # etc...

Hope that helps.  Dig around and you may even find better ways to accomlpish
this.

Matt

Reply via email to