Apache::Template is a simple drop-in way to use tt2 with Apache.
However, its simplicity has a few drawbacks.  The main one I ran into
was similar to yours.  Since Apache::Template only deals with one
template object, its tricky (if not impossible) to have different configs
for different sites in the way you describe below.

The good news is that you don't need to use Apache::Template.  Write
your own handler instead.  I'm just getting started with tt2 myself,
so I will leave it to others to expound on this aspect.  (or check the
list archive) 

The bad news is that even with your own handler, keeping separate
configs in the same template object is tricky.  You can either have
multiple objects (which probably doesn't scale well if you've got
thousands of domains on the same machine) or you can hack the tt2 code
like I did.

I made a couple simple tweaks that allowed me to keep separate
INCLUDE_PATHs and PLUGIN_BASEs in a single template object.  I'm
not familiar enough with the other settings you mentioned to know
how hard they are to set on a per-domain basis.

http://www.template-toolkit.org/pipermail/templates/2002-March/002870.html
http://www.template-toolkit.org/pipermail/templates/2002-March/002858.html

So, if you only have two hosts write a handler that instantiates two
template objects and passes the request to the correct one.  If you
have a hundred hosts, you'll probably need to hack the tt2 source.

-Blake

On Tue, Apr 09, 2002 at 09:36:36PM -0400, Peter Marshall wrote:
> I am having problem with Apache::Template in a multiple virtual host
> envrionment.
> 
> Here is the httpd.conf segment to ilustrate setup.
> 
> # Turn on Apache::Template
> PerlModule Apache::Template
>     TT2Trim     On      
>     TT2PostChomp        On
>     TT2EvalPerl     On
> 
> <VirtualHost 123.456.789.000>
>     ServerAdmin joe
>     DocumentRoot /usr/local/www.host1.com
>     ServerName www.host1.com
>     TT2IncludePath /usr/local/www.host1.com/lib
>     TT2Error        error
>     TT2PreProcess       config header
>     TT2PostProcess  footer
>     ErrorLog logs/www.host1.com-error_log
>     CustomLog logs/www.host1.com-access_log combined
>     ScriptAlias /cgi-bin /usr/local/www.host1.com/cgi-bin
>     Alias /images/ "/usr/local/www.host1.com/images/"
>     <Directory "/usr/local/www.host1.com/">
>         Options FollowSymLinks MultiViews
>         AllowOverride All
>      </Directory>
>      DirectoryIndex index.tt2
> <Files *.tt2>
>         SetHandler perl-script
>         PerlHandler Apache::Template
> </Files>
> </VirtualHost>
> 
> <VirtualHost 123.456.789.000>
>     ServerAdmin Harry
>     DocumentRoot /usr/local/www.host2.com
>     ServerName www.host2.com
>     TT2PreProcess  mmt-header menu
>     TT2PostProcess  mmt-footer
>     TT2IncludePath      /usr/local/www.host2.com/lib
>     TT2Error     mmt-error
>     ErrorLog logs/www.host2.com-error_log
>     CustomLog logs/www.host2.com-access_log combined
>     ScriptAlias /cgi-bin /usr/local/www.host2.com/cgi-bin
>     Alias /images/ "/usr/local/www.host2.com/images/"
>     <Directory "/usr/local/www.host2.com/">
>         Options FollowSymLinks MultiViews
>         AllowOverride All
>      </Directory>
>      DirectoryIndex index.tt2
>  <Files *.tt2>
>         SetHandler perl-script
>         PerlHandler Apache::Template
>  </Files>
> </VirtualHost>
> 
> At unpredictable and random times the one going to 
> 
> http://www.host1.com 
> 
> Will result in the HOST2 Preloads being executed (header, menu footer).
> 
> Another random event is a unknown error will be thrown say in host1
> and the host2 error module will be executed.
> 
> Have I got set-up wrong?? 
> 
> Any help would be appreciated since will have to abandon the Toolkit
> if we can't get around this.
> 
> --
> Peter Marshall -- CTO Openphase
> "The The secret to creativity is knowing how to hide your sources."  A.Einstein
> "The magic is in the doing" - P. Marshall
> 
> _______________________________________________
> templates mailing list
> [EMAIL PROTECTED]
> http://www.template-toolkit.org/mailman/listinfo/templates


Reply via email to