[Zope] ZopeTime() in python script ...

Mike Blake mike.blake@cellnetwork.com
Thu, 10 May 2001 13:56:17 +0200


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