* Perrin Harkins <[EMAIL PROTECTED]> [2002-06-18 10:38]:
> darren chamberlain wrote:
> > The way Apache::Template is setup, Location based directives do random
> > things, so this isn't as useful in practice as it is in theory.
>
> That's frustrating. I was hoping there would be an easy transition for
> people who started off with Apache::Template to a more elegant
> application design.
It has more to do with how mod_perl integrates into Apache than it does
with Apache::Template, I think.
> > Changing Service modules per requests under Apache::Template will
> > lead to unpredictable results.
>
> Why is that? It seems like a reasonable thing to do.
Apache::Template::handler caches the Service instance (from 0.06):
65 $SERVICE ||= do {
66 my $cfg = Apache::ModuleConfig->get($r) || { };
67
71 $cfg = { %$cfg };
72
73 # instantiate new service module
74 my $module = $cfg->{ SERVICE_MODULE } || $SERVICE_MODULE;
75 (eval "require $module" && $module->new($cfg)) || do {
76 $r->log_reason($module->error(), $r->filename());
77 return SERVER_ERROR;
78 };
79 };
Which means that each child has it's own (static) Service module. A
call to TT2ServiceModule in a <Location> directive will not be looked
at if it's not the first request that child handles (because of the
$SERVICE ||= part on line 65), and if that request is the first one a
child handles, then that Service module will be used to handle all
subsequent requests, which is probably not what is intended.
All things considered, the reusing of a single Service instance gains
you more than you lose by not being able to specify specific service
modules for individual Locations; if you need to do the latter, you have
probably outgrown Apache::Template.
In my experience, changing ServiceModules on the child leads to
segfaults.
(darren)
--
Nothing worse could happen to one than to be completely understood.
-- Carl Gustav Jung