I'm currently using Template as part of a web-content generating FastCGI
script. The logic in the script implements two features I can't see an
easy way to integrate with Template:

  1. It caches the contents of files, keyed on filename, updating the
     cache only when the file's mtime changes.

  2. It tracks the latest mtime of any file (or other data) used during
     the building of the page, in order to set the "Last_Modified:"
     header on reply and to implement the "If_Modified_Since:" logic.

The problem here is that the page's template file could reference any
other file within the template path, by giving an

 [% INCLUDE foo.tmpl %]

directive, and my code wouldn't know about it.

My question therefore, is how can I hook into the template file
providing code, with my own code?

Problem 2 is a much larger one for me, than problem 1. I know Template
does its own caching of parsed content, so I don't imagine I'd gain too
much from 1. But, given as 2 isn't implemented right, my FastCGI returns
a "304 Not Modified" status falsely; whenever an included file has been
modified that it doesn't know to check.

I have noticed the ability to replace Template's various classes with
different objects - perhaps this is the way to do it? Provide a custom
subclass of the object which provides template file contents; which
informs my FastCGI code of that template file's use.

Would this work recursively? If page INCLUDEs foo INCLUDEs bar, if just
bar is now modified, do we still walk the entire tree looking for mtime
changes?

-- 
Paul "LeoNerd" Evans

[EMAIL PROTECTED]
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/

Attachment: signature.asc
Description: Digital signature

Reply via email to