Using DTML or Python in ZClass Properties?
I have a ZClass with a property that is a date. I would like that property's value to contain the current date as a default, subject to user override. In the ZClass Property Sheet editor, I can't seem to get a DTML expression to work. Maybe I'm formatting it wrong, but I keep getting an invalid date string kind of answer. One document I read suggested that I could put the date into the object's constructor method by calling manage_editProperties, but it made a reference to "if you add fields for properties to the HTML form on the management screen" and that was just imprecise enough that it eludes me. Any ideas?
Dan Shafer writes:
I have a ZClass with a property that is a date. I would like that property's value to contain the current date as a default, subject to user override. This is not possible (as you found out).
The next thing you can come at it to set the date in your Z instance constructor. Of course, it is then fixed at instance creation time. Dieter
Thanks. I was afraid of that. Seems like a bit of an oversight but I'll live with it. Dieter Maurer wrote:
Dan Shafer writes:
I have a ZClass with a property that is a date. I would like that property's value to contain the current date as a default, subject to user override. This is not possible (as you found out).
The next thing you can come at it to set the date in your Z instance constructor. Of course, it is then fixed at instance creation time.
Dieter
Dan Shafer wrote:
Thanks. I was afraid of that. Seems like a bit of an oversight but I'll live with it.
Dieter Maurer wrote:
Dan Shafer writes:
I have a ZClass with a property that is a date. I would like that > property's value to contain the current date as a default, subject to user override. This is not possible (as you found out).
The next thing you can come at it to set the date in your Z instance constructor. Of course, it is then fixed at instance creation time.
Dieter
What about something like this, in your "yourZClass_add" method - assuming your property is called "mydate": <dtml-unless name="mydate"> <dtml-call expr="REQUEST.set('mydate', _.DateTime())"> </dtml-unless> <dtml-call "propertysheets.Basic.manage_editProperties(REQUEST)"> Sorry if this isn't answering the question, I seemed to miss the original post. -Paul
participants (3)
-
Dan Shafer -
Dieter Maurer -
Paul Erickson