Re: [Zope] Problems using DateTime in dtml and python. Help...
Date: Thu, 30 Mar 2000 01:47:36 -0500 To: zope@zope.org Subject:
I have been building an interface for call reports from a MySQL database on linux slackware 7 using recent source distributions of Zope ,MySql and python. Besides a messy bout with the ZMySQLDA source, which is now not an issue, I've done OK. The problems:
1:
I can call the DateTime() function from dtml like this- <dtml-var "_.DateTime(a_later_time) - _.DateTime(an_earlier_time)"> and I get what I need - a duration of time- but in days. Is there a method to change this to minutes and seconds or do I just do my own math ... result * 24 * 60 etc... Whenever I try to use the DateTime objects, eg fmt=DayOfWeek etc, I get invalid attribute errors.
2:
I would rather do this work in an External Method, but when I try to use DateTime() in a method I get a Name Error when I try to update the Eternal Method in Zope.
So I went to the python command line.
from DateTime import * Traceback (innermost last): File "<stdin>", line 1, in ? ImportError:No module named DateTime
Obviously, I have some work to do, but what ? Recompile Python or Zope ?
How do I get DateTime to be recognized as a module? I noted that the contents of the Setup file in /Zope/lib/python/DateTime are commented out- # install DateTime.py # install DateTimeZone.py I uncommented them for kicks and reinstalled Zope with the same results.
It seems to me I'm missing something OBVIOUS. And help greatly appreciated... David Troy
Convert the DateTime objects to seconds before subtracting:: <dtml-let early="_.DateTime(an_earlier_time)" late="_.DateTime(a_later_time)" <dtml-var "_.float( late ) - _.float( early )"> </dtml-let> You can use '_.int(..)' or '_.long(..)', to, truncating to whole seconds. Tres. -- ========================================================= Tres Seaver tseaver@digicool.com tseaver@palladion.com
participants (1)
-
Tres Seaver