I have two issues, one dealing with template processing, and the other
dealing with template caching.

the first issue, I'm using mod_perl and apache to process all .phtml
files as TT2 templates, using this PerlHandler:
   sub handler {
     # load apache request object
     my $request = shift;

     # display 404 if requested template file does not exist
     return NOT_FOUND unless(-e $request->filename());

     # unless a Template object already exists, create new
     $TT ||= Template->new({
       INCLUDE_PATH => $ENV{'DOCUMENT_ROOT'},
       ABSOLUTE     => 1,
       EVAL_PERL    => 1,
       LOAD_PERL    => 1
     });

     # print content-type and process template
     $request->content_type('text/html');
     $TT->process($request->filename(), { 'uri' => $request->uri },
$request ) || do
     {
       $request->log_reason( $TT->error() );
       return SERVER_ERROR;
     };

     # return status to mod_perl
     return OK;
   }

this modules compiles and runs just fine.  now, when I try to display
a page that contains the following text:
   Testing
   ...
   Testing 1 2 3
   ...

I somehow get this served from apache:
   <html><head></head><body>TiTi13</body></html>

i'll be honest, i have no idea whats happening here.  the mangling of
the page content is pretty obvious, but I'm not sure why its mangling
it.  plus, i have NO idea where those html tags are coming from...

as for my second problem, the caching issue...I'm using absolute paths
to retrieve my templates (from a mod_perl handler, so it could come
from outside of the server's DOCUMENT_ROOT, if there's a spurious use
of Aliases), and I'd like to cache the compiled templates for
performance.  however, if i enable caching *with* absolute paths:
   ABSOLUTE => 1,
   COMPILE_DIR => "/home/test/cache"

I get a 500 (internal server error).  for instance, if someone
requests the template file '/home/test/public_html/test.phtml', I get
this error in my apache log:
   mkdir /home/test/cache//home: Permission denied at
   /usr/lib/perl5/vendor_perl/5.8.8/i386-linux/Template/Provider.pm line 398
   "/var/log/apache2/error_log" [converted] 54L, 2804C

It seems like its automatically adding a trailing slash to
COMPILE_DIR, and then choking on the leading slash of the absolute
path of the template file...Is this a bug?  If so, any ideas for a
workaround?

_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to