[Zope-dev] Last-modified and bobobase_modification_time

Steve Alexander steve@cat-box.net
Fri, 14 Jun 2002 14:38:11 +0100


Casey Duncan wrote:
> BTW: This list if for development *of* Zope, the zope@zope.org list is
> better for questions bout developing *with* Zope.
> 
> On to your question:
> 
> There is no automatic way in which DTML can do this for you. This is
> simply because <dtml-var foo> doesn't tell Zope what foo is. Is it a
> document or a script that returns something different every time it is
> called or something else? In fact foo might different things at
> different times, if you aquire the template into different contexts.
> 
> Anyhow, if you really want to set a Last-Modified header that reflects
> the latest of a group of documents, you can write a python script that
> accepts either a list of names or objects to test. For the latter here's
> a Py script named "setLastModTime" with a single argument, "*objects":
> 
> last_mod = objects[0].bobobase_modification_time()
> for ob in objects[1:]:
>     last_mod = max(last_mod, ob.bobobase_modification_time())
> context.REQUEST.RESPONSE.setHeader('Last-Modified', last_mod.rfc822())
> return last_mod # for debugging purposes
> 
> Then from dtml:
> 
> <dtml-call expr="setLastModTime(this(), fooMethod, barDocument, ...)">

A similar approach would be for each page fragment to set the 
Last-Modified head if either there is no header set, or its own 
last-modified time is later than one that is set.

--
Steve Alexander