[ZPT] rdb and strftime

Magnus Heino magnus.heino@pleon.sigma.se
Wed, 26 Jun 2002 07:56:47 +0200


>> Why am i not allowed to strftime psycopg results in zpt?
> 
> 
> If I didn't know the identifiers involved, I'd think that sentence had 
> been partially encrypted :-)

=)

> How do you mean?  As in "python:rec.datefield.strftime('%Y')"?  Psycopg 
> likes to return mxDateTimes rather than DateTimes, and that may the 
> problem.

Maybe I've got something wrong, its been a long while since I had to use 
sql databases.

Ive got a Psycopg database setup, and a connection "db" to it in Zope. 
It doesnt matter if I tell Psycopg to use mxDateTime or DateTime.

I've got a sql object "getAllTemperatures" like this; "select time, 
value from temperatures;". time is of type datetime and value is a float.

Then in the PT I do;

<tr tal:repeat="temperature here/getAllTemperatures">
   <td tal:content="python:temperature['time'].strftime('%Y-%m-%d %H:%M')"/>
   <td tal:content="temperature/value"/>
</tr>


If browse this page as manager, I the basic auth login will pop up. If I 
hit cancel, the error message is "You are not allowed to access strftime 
in this context", or something very simular. (I dont have access to it 
right now).

So, am I doing something stupid?

Thanks,

/Magnus