> I'm just trying to write code in a config reader that reads
> server->dir_config when it's loaded into apache, and request->dir_config
> when it is called during requests.

all your other questions aside for the moment, I don't understand from where
you might be trying to do that.

  My::Package;

  # this code executes on server startup when using PerlModule

  sub handler {
    # this code executes on each request
  }

if you're worried about the server part being called when the module is
being loaded initially during a request (say, if someone didn't use
PerlModule) then something like this might work

  my $r_or_s = eval { Apache2::RequestUtil->request } ||
                      Apache2::ServerUtil->server;

  my $value = $r_or_s->dir_config($key) || $ENV{$key} || $default;

or somesuch.

keep in mind that $s->dir_config won't contain the results of a
per-directory merge, while $r->dir_config will.  so $value might be
different depending on whether you use $r or $s, even during request time.

if that's not what you mean, then under what circumstances might you want to
call the exact same block of code where it may or may not be during a
request?  that might help us focus on what you need to do a bit better.

HTH

--Geoff

Reply via email to