[Templates] Two issues - Processing problem and caching problem
(bug?)
Josh Rosenbaum
josh@infogears.com
Wed, 12 Jul 2006 10:13:09 -0600
Evan Kaufman wrote:
> # unless a Template object already exists, create new
> $TT ||= Template->new({
> INCLUDE_PATH => $ENV{'DOCUMENT_ROOT'},
> ABSOLUTE => 1,
> EVAL_PERL => 1,
> LOAD_PERL => 1
> });
I'm going to preface my response with the following disclaimer: I have not used Template Toolkit in this manner and what I say may be completely wrong. If it is, please feel free to ignore me. If nothing else, maybe it'll give you some ideas of how to move on. I feel a little more confident on the mkdir response below.
Ok, for the above code, remember that on each request if $ENV{'DOCUMENT_ROOT'} changes, it will not be changed in $TT since it already exists. I'm not sure $ENV{'DOCUMENT_ROOT'} will ever change, though, so this may not be an issue. If it did, then your paths would be screwed up, and you may access a Template elsewhere. You might also want to check that the path is what you think it is. You might also want to check that $request->filename() goes to where you think it will go. It seems like you are loading another file to me.
> 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?
I think this mkdir syntax should be fine. Make sure your permissions are set correctly on /home/test/cache so that whatever user TT is running as can create directories and such. Maybe just chmod the dir to 777 to test.
-- Josh