[Templates] Apache::Template's TT2* conf cannot be in .htaccess ?

darren chamberlain dlc@users.sourceforge.net
Thu, 21 Nov 2002 08:22:53 -0500


* Randal L. Schwartz <merlyn@stonehenge.com> [2002-11-20 22:54]:
> I'm pretty sure that in one of the older versions of Apache::Template
> I was able to put thinks like TT2Include in an .htaccess file.
> However, I can't seem to do it now.
> 
> Is there a technical reason as to why the conf items are only
> "RSRC_CONF", thus denying their use in an htaccess?

Apache::Template creates global Service and Parser instances
(shared among all virtual hosts) -- the first request a child handles
creates these instances and then doesn't recreate them.  If you have:

  TT2Interpolate On
  <Location /some/where>
    TT2Interpolate Off
  </Location>

And a child's first request is for /some/where, then that child's
objects will be permanently created with INTERPOLATE => 0, even though
the second request it handles is for / (which should have INTERPOLATE =>
1).  This is clearly the wrong behavior for /, but to make it work the
way you're expecting, the Parser and Service objects would have to
either be recreated for each request (expensive, but doable) or each
request would have to go through the gynmastics of querying (and
potentially updating) every configurable data member that those objects
have.  Actually, many of those object's data members are not
usefully-modifiable after instantiation (like the FACTORY member of
Template::Grammar, for instance) or don't have mutator methods (which
means mucking with @{ $service->{ LOAD_PROVIDERS } }, for example).

The same problems apply with virtual hosts:

  <VirtualHost foo>
    TT2PluginBase  Foo::Plugin
  </VirtualHost>

  <VirtualHost Bar>
    TT2PluginBase  Bar::Plugin
  </VirtualHost>

You see where this is leading.

The easiest fix is to make the service et al non-persistant.  I've got a
patch against 0.06 that implements this fix (and some other small
fixes). If you're interested, I can send it you and/or post it.

(darren)

-- 
My one regret in life is that I am not someone else.
    -- Woody Allen