[ZPT] Modification Time

Sam Collett Sam.Collett@gp-b81091.trent.nhs.uk
Mon, 17 Dec 2001 16:49:04 -0000


I get an error when I try this.

Zope Error
Zope has encountered an error while publishing this resource.

Error Type: TALESError
Error Value: exceptions.AttributeError on bobobase_modification_timestrftime
in "", at line 17, column 16

I found the following at the bottom:

File C:\Program
Files\WebSite\lib\python\Products\PageTemplates\ZRPythonExpr.py, line 49, in
__call__
    (Info: template.bobobase_modification_time.strftime('%d/%m/%Y'))
  File Python expression
"template.bobobase_modification_time.strftime('%d/%m/%Y')", line 2, in f
    (Object: guarded_getattr)
  File C:\Program Files\WebSite\lib\python\AccessControl\ZopeGuards.py, line
47, in guarded_getattr
    (Object: bobobase_modification_time)


What does guarded_getattr mean?

-----Original Message-----
From: Evan Simpson [mailto:evan@zope.com]
Sent: 17 December 2001 15:33
To: Sam Collett
Cc: ZPT List (E-mail)
Subject: Re: [ZPT] Modification Time


Sam Collett wrote:

> I want to be able to change the format of the following into UK format
> (DD/MM/YY HH:MM).
> 
> Last Modified: <b
> tal:content="string:${template/bobobase_modification_time}"></b>
> 
> I know how to do it in dtml, but how to you do it with page templates?


Date formatting is peformed internally with the "strftime" method of 
DateTime objects.  You can use it explicitly, like so:

tal:content="python:template.bobobase_modification_time.strftime('%d/%m/%Y')
"

Note that writing "string:${a/b}" is equivalent to, but less efficient 
than, plain "a/b".

Cheers,


Evan @ Zope