[Zope] ZopeTime() in python script ...
Peter Bengtsson
mail@peterbe.com
Thu, 10 May 2001 14:40:55 +0200
DTML
<dtml-var ZopeTime> == <dtml-var "ZopeTime()">
Python Script
timeobject = context.ZopeTime()
day = timeobject.strftime('%A')
Hope this helps!
peter
----- Original Message -----
From: "Mike Blake" <mike.blake@cellnetwork.com>
To: <zope@zope.org>
Sent: Thursday, May 10, 2001 1:56 PM
Subject: [Zope] ZopeTime() in python script ...
> Hi!
>
> I have a messy dtml block that returns a yyyymmdd date
> string using zope time:
>
> # <dtml-var "(ZopeTime()).year()"
> # ><dtml-if
> # expr="(ZopeTime()).month()<10"
> # >0<dtml-var "(ZopeTime()).month()"
> # ><dtml-else
> # ><dtml-var "(ZopeTime()).month()"
> # ></dtml-if
> # ><dtml-if
> # expr="(ZopeTime()).day()<10"
> # >0<dtml-var "(ZopeTime()).day()"
> # ><dtml-else
> # ><dtml-var "(ZopeTime()).day()"
> # ></dtml-if>
>
> This works, BUT I would like to forget the dtml
> and just write it in python. Something like this?:
>
> # str=""
> # str = str + ZopeTime().year()
> # if ZopeTime().month()<10:
> # str = str + "0"
> # str = str + ZopeTime().month()
> # if ZopeTime().month()<10:
> # str = str + "0"
> # str = str + ZopeTime().day()
> # return str
>
> But this gives an error:
> Error Type: NameError
> Error Value: ZopeTime
>
> I have this as a python script object and although
> it would return a string ok, I get an error when
> trying to access ZopeTime().
>
> I am currently losing my mind trying different
> arguments and import statements, but getting nowhere
> fast. How do I access the variables and methods
> (those that would normally be available to a dtml
> method) in a python script?
>
> thanks,
> mike
>
> --
> [morcilla@ketden.com chikoon]$ whoami
> Mike Blake
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )