template last modification time

3 views
Skip to first unread message

Manlio Perillo

unread,
Oct 2, 2007, 11:09:00 AM10/2/07
to mako-d...@googlegroups.com
Hi.

Is it possible to have access to the last modification time of a template?

I need it to properly set the Last-Modified header (when only the
template has been modified, and not the data source).

The Template object has a _last_modified attribute that works as I want,
but it is private.

Thanks Manlio Perillo

Michael Bayer

unread,
Oct 3, 2007, 10:23:40 AM10/3/07
to mako-d...@googlegroups.com
certainly you should use _last_modified for now. we can look into
making those variables non-underscored in the next release.

Jose Galvez

unread,
Oct 3, 2007, 10:51:18 AM10/3/07
to mako-d...@googlegroups.com
I tried ${_last_modified } and ${self._last_modified } neither give me
the expected date. How do you _last_modified?
Jose

Manlio Perillo

unread,
Oct 3, 2007, 11:01:45 AM10/3/07
to mako-d...@googlegroups.com
Michael Bayer ha scritto:

> certainly you should use _last_modified for now. we can look into
> making those variables non-underscored in the next release.
>

Thanks.

> On Oct 2, 2007, at 11:09 AM, Manlio Perillo wrote:
>
>> Hi.
>>
>> Is it possible to have access to the last modification time of a
>> template?
>>
>> I need it to properly set the Last-Modified header (when only the
>> template has been modified, and not the data source).
>>
>> The Template object has a _last_modified attribute that works as I
>> want,

A precisation: the attribute is "_modified_time" and it is defined in
the "module" attribute of the Template object (and it seems that it is
always defined, even for string based templates).


Manlio Perillo

Michael Bayer

unread,
Oct 3, 2007, 11:06:11 AM10/3/07
to mako-d...@googlegroups.com
it wont work from inside the template, since _last_modified will
replace itself with a contextual variable. in the template you can
get to it as self.module._last_modified (its also a one liner to add
self.last_modified to namespace....).

Jose Galvez

unread,
Oct 3, 2007, 11:29:52 AM10/3/07
to mako-d...@googlegroups.com
Cool thanks
Jose
Reply all
Reply to author
Forward
0 new messages