Re: [Zope] - HTMLFile-like class that heeds DTML mod time
Cool! I was fiddling around last night trying to do the same thing, but none of my attempts were this simple. Thanks! -- Robin Dunn robin@AllDunn.com http://AllDunn.com/robin/ Try http://AllDunn.com/laughworks/ for a good laugh. -----Original Message----- From: skip@calendar.com <skip@calendar.com> To: zope@zope.org <zope@zope.org> Date: Wednesday, January 13, 1999 6:18 PM Subject: [Zope] - HTMLFile-like class that heeds DTML mod time
I got tired of having to restart my ZopeHTTPServer every time I twiddled a DTML file used by a published object, so I wrote the following simple class that checks the mod time of the DTML file when it's called, and recreates its HTMLFile instance if necessary. I instantiate it instead of HTMLFile.
class Template: def __init__(self, file): self.file = file self.template = DocumentTemplate.HTMLFile(self.file) self.ftime = os.stat(self.file)[stat.ST_MTIME]
def __call__(self, *args, **kargs): ftime = os.stat(self.file)[stat.ST_MTIME] if self.ftime < ftime: self.ftime = ftime self.template = DocumentTemplate.HTMLFile(self.file) return apply(self.template.__call__, args, kargs)
I'm sure there's probably a simple way to integrate this into DocumentTemplate.HTMLFile directly, but this seemed easier to me, what with the mixins and such that are used in DocumentTemplates, and all I really need are __init__ and __call__ methods.
Consider this a feature request (I also submitted it to the Zope web site.)
Skip Montanaro | Mojam: "Uniting the World of Music"
skip@calendar.com | Musi-Cal: http://concerts.calendar.com/ 518-372-5583
participants (1)
-
Robin Dunn