[Zope] on dates

massimop at users.berlios.de massimop at users.berlios.de
Mon Oct 11 13:48:01 EDT 2004


On Mon, 2004-10-11 at 19:15 +0200, Andreas Jung wrote:
> 
> --On Montag, 11. Oktober 2004 19:04 Uhr +0200 massimop at users.berlios.de 
> wrote:
> 
> > I'm trying to format a Date retrieved from MySQL, but while I can print
> > the date as it is I can't access any of the methods, so no strftime()
> > and no day() etc
> > I get a 'not allowed in this context' exception
> > so:
> > <i tal:content="python:item.data"></i>
> > is ok but:
> > <i tal:content="python:item.data.day"></i>
> > causes Zope to ask for authentication
> >
> 
> No idea about mysql-python but I assume that is returns date fields from 
> MySQL
> as DateTime instance to Zope and to your application. So you should be able 
> to
> use the DateTime API. If 'data' in your example above should be a DateTime 
> instance
> that you are accessing member variable *instead* of *calling* a DateTime 
> *method*.
> 
> -aj
I think is a DateTime instance because if I try any of his attributes or
methods i get 'not allowed in this context' while if I try with an
arbitrary attributes (say item.data.phony) I get

Error Type: AttributeError
Error Value: 'datetime.datetime' object has no attribute 'phony'

so I suppose that item.data has an attribute day (according to DateTime
documentation day is an 'Instance attribute')

anyway, in case is significant, 'item.data' in the example returns a
full specified datetime like:

2004-10-11 19:14:47


... no idea....

thanks
massimo




More information about the Zope mailing list