Python Syntax within DTML
Hello List. I'm having a little trouble correctly referencing python within a DTML method. I'm attempting to set some values using the dateclass class. <input type='hidden' name='start_date' value='<dtml-var expr="date.toordinal()">'></input> I'm just trying to get todays date in ordinal form, so that I can perform some manipulations upon it. Do I need to use request.set or am I on the wrong tangent? Thanks in advance Julian
I think you mean the DateTime class. You can get one in DTML with <dtml-var "_.DateTime(args)"> or <dtml-var ZopeTime>. Check eg http://zwiki.org/ZopeBookAppendixBAPIReference#DateTime
Support Faults wrote at 2003-8-26 14:35 +0800:
I'm having a little trouble correctly referencing python within a DTML method. I'm attempting to set some values using the dateclass class.
<input type='hidden' name='start_date' value='<dtml-var expr="date.toordinal()">'></input>
I'm just trying to get todays date in ordinal form, so that I can perform some manipulations upon it.
Do I need to use request.set or am I on the wrong tangent?
You did not tell us what happened, what went wrong... Please do that in the future when you report problems. Zope usually uses "DateTime.DateTime.DateTime" instance to represent dates and times. Looking at their documentation, they do not have a method "toordinal". "JulianDay" may be something similar. Chack the documentation! Guessing from your description, your "date" might be a Python 2.3 "date" instance. Almost surely, such classes do not have the necessary Zope security declarations and accessing them will probably raise an "Unauthorized" exception. If this does not help you, come back with more information. Do it straight away in the future! Dieter
participants (3)
-
Dieter Maurer -
Simon Michael -
Support Faults