Hmmm,

Apache::Template only allows me to have one service module. I cannot
define different TT2ServiceModule's in different vhosts and have them work
as I would expect.

Attached patch seems to fix that so that Template::Config::SERVICE is set
correctly before ->service( $cfg ) is called.

It has not been extensively tested but it seems to work for me.

Simon.

-- 
"The school band will now murder 'Oh Come All Ye Faithful'"
--- lib/Apache/Template.pm      2004-04-27 10:11:31.000000000 +0100
+++ /usr/lib/perl5/Apache/Template.pm   2004-10-20 10:52:58.000000000 +0100
@@ -23,7 +23,7 @@
 package Apache::Template;
 
 use strict;
-use vars qw( $VERSION $DEBUG $ERROR $SERVICE );
+use vars qw( $VERSION $DEBUG $ERROR $SERVICE $SERVICE_MODULE );
 
 use DynaLoader ();
 use Apache::ModuleConfig ();
@@ -34,7 +34,7 @@
 $VERSION = '0.09';
 $ERROR   = '';
 $DEBUG   = 0 unless defined $DEBUG;
-$Template::Config::SERVICE = 'Template::Service::Apache';
+$SERVICE_MODULE = 'Template::Service::Apache' unless defined $SERVICE_MODULE;
 
 if ($ENV{ MOD_PERL }) {
     no strict;
@@ -69,6 +69,9 @@
         my $cfg = Apache::ModuleConfig->get($r) || { };
 #        warn "setup service for hostname: ", $r->hostname, "  ($cfg):\n", 
 #             dump_hash($cfg), "\n";
+        $Template::Config::SERVICE = (defined $cfg->{ SERVICE_MODULE })
+                                   ? $cfg->{ SERVICE_MODULE }
+                                   : $SERVICE_MODULE;
         Template::Config->service($cfg) || do {
             $r->log_reason(Template::Config->error(), $r->filename());
             return SERVER_ERROR;
@@ -387,7 +390,7 @@
 
 sub TT2ServiceModule($$$) {
     my ($cfg, $parms, $module) = @_;
-    $Template::Config::SERVICE = $module;
+    $cfg->{ SERVICE_MODULE } = $module;
 }
 
 #------------------------------------------------------------------------

Reply via email to