Don't know if I really got it right but why not do something like
<PERL>
my @loc = qw[/uri1 /uri2 /uri3];
foreach (@loc) {
$Location{$_} = {
PerlHandler => "Apache::SomeModule",
SetHandler => "perl-script",
};
Apache::SomeModule->dosmeconfig($_);
}
</PERL>
Robert Bedell wrote:
> I've hunted all over the place for this, and still haven't found the
> solution. I remember seeing it for the C api, but not for Apache::*.
> I own the O'Reilly book and do quite a bit of mod_perl programming, so
> if someone can help me on this I'd appreciate it.
>
> I have some setups where I need to separate the configuration based on the
> directory/location it's being loaded from. Like this:
>
> <Location /uri>
> SetHandler perl-script
> PerlHandler Apache::SomeModule
> <Perl>
> Apache::SomeModule->dosomeconfig(....);
> </Perl>
> </Location>
>
> In other words, I want to be able to see that it's in /uri in the perl
> section. Or rather, the class method inside it. This may seem trivial,
> but I also don't want to use the string '/uri' anywhere in in the <Perl>
> section.
>
> In the past I've been pressed for time so I've simply added a PerlSetVar
> for a key of some sort and used that key when configuring:
>
> PerlSetVar SomeModule_Key 'set1'
> ...
> <Perl>
> Apache::SomeModule->dosomeconfig('set1',....);
> ...
>
> However I do not like this approach. It puts the task on the administrator
> to maintain the separation of information by key - sometimes useful,
> perhaps, but not often.
>
> An example of an application this is being used for is a module I wrote up
> called Apache::Template, which loads templates in memory and then lets you
> bind parts of the URI in order to fill them in and process them to the user.
> The solution is appropriate for the application, so please, no questions
> like 'well if you changed the application'.
>
> I've looked through Apache::Server, tried dir_config and various other
> things, and still have no luck. Since this problem has persisted, and I no
> longer recollect the C api that does what I'm looking for, does someone else
> know what is? If it does not exist, or simply is not well documented, can
> we (I volunteer) do it?
>
> Thank you.
>
> PS - I have a module called Apache::XMLRPC that uses Frontier::RPC2 to implement the
> corresponding spec. Is there anything currently out there that does this?
> If not, I'll release it.
>
> --Oddfellow