[Zope] Python2.3 datetime VS Zope DateTime
zope at netchan.cotse.net
zope at netchan.cotse.net
Fri Mar 26 11:53:47 EST 2004
I had the same problem before:
http://marc.theaimsgroup.com/?l=zope&m=107784430723371&w=2 I was
suggested to use Zope's DateTime, however I don't want to use Zope
specific stuff where there's a python alternative.
I created a small wrapper around the datetime object:
class dtwrap(datetime):
__allow_access_to_unprotected_subobjects__ = 1
Wherever I'd pass a datetime 'D' to a zpt, I pass getdwrapper(D)
instead, where getdwrapper is:
def getdwrapper(d):
return dtwrap(d.year, d.month, d.day, d.hour, d.minute,
d.second, d.microsecond)
Anyway, it would be nice if zpt could handle the native python datetime.
Regards,
Sandor
> -----Original Message-----
> From: zope-bounces+zope=netchan.cotse.net at zope.org
> [mailto:zope-bounces+zope=netchan.cotse.net at zope.org] On
> Behalf Of Sakesun Roykiattisak
> Sent: Friday, March 26, 2004 6:44 AM
> To: Small Business Services
> Cc: zope at zope.org
> Subject: Re: [Zope] Python2.3 datetime VS Zope DateTime
>
>
> In fact, I mean python2.3's datetime.datetime. However, with
> your hint,
> I've found I can do this.
>
> <dtml-let d="getInvoiceDate('INV10001')">
> <dtml-var "_.DateTime(str(d)).strftime('%d/%m/%Y')">
> </dtml-let>
>
> or in ZPT
>
> <span tal:omit-tag="" tal:define="d
> python:here.getInvoiceDate('INV10001')">
> <span tal:replace="python:DateTime(str(d)).strftime('%d/%m/%y)"/>
> </span>
>
> Ther are pretty verbose. But it works anyway.
>
>
> Thank you very much for your tip.
>
> Small Business Services wrote:
>
> >From: "Sakesun Roykiattisak" <sakesun at boonthavorn.com>
> >
> >
> >>I'm now trying to publish a set of database-related logics through
> >>zope. Some of them return a python2.3's datetime object which its
> >>member access are disallowed from zope. (DTML, ZPT)
> >>I want to access some of datetime's member-methods, like strftime &
> >>isocalendar. How can I make it accessible from zope ? Or
> how can I make
> >>Zope automagically convert it to Zope's DateTime. I really
> don't want
> >>to change my logics to use Zope's DateTime.
> >>
> >>
> >
> >DateTime and strftime are accessible from dtml:
> >
> ><dtml-let e="_.DateTime()">
> > strftime(%Y/%m/%d) --> <dtml-var expr="e.strftime('%Y/%m/%d')">
> ></dtml-let>
> >
> >
> >Jonathan
> >
> >
> >
> >
>
>
>
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>
More information about the Zope
mailing list