[Zope] Initialization of properties in a ZClass instance?

Kevin Dangoor kid@kendermedia.com
Tue, 14 Sep 1999 13:42:25 -0400


-----Original Message-----
From: Darran Edmundson <Darran.Edmundson@anu.edu.au>
To: zope@zope.org <zope@zope.org>
Date: Tuesday, September 14, 1999 4:59 AM
Subject: [Zope] Initialization of properties in a ZClass instance?


>The problem is that
>/Products/NewsItemProduct/NewsItemClass/propertysheets/common/NewsItemPrope
rties
>will not allow me to add a "date" property of type date and
>leave it blank.  Ideally, I would like this property to
>default (ie. automatically initialize) to the current datetime.
>How does one achieve this?  (My guess is that I give it a
>dummy value in the class definition and then set it in the
>constructor method?).

Your guess is exactly what I do.

>This raises the question: does every object instance have
>a creation datetime even though it doesn't explicitly appear
>on the Properties tab, and if so, is this value available
>in a DTML method.

This has been talked about earlier on the list. I believe the answer from
the DC guys was that the object creation time is not stored in the ZODB
(only the last modification time).

>On an unrelated note, how can I make each instance of NewsItem's
>index_html method autmatically visible in the Contents tab and
>available for editing?

If index_html is a method of the ZClass, it cannot be overridden at the
instance level. My method for doing this is to create a DTML method in the
ZClass called "default_index_html". Then, the constructor copies the
contents of this to a new DTML method inside the instance (that one is
called just "index_html"). For convenience sake, I also made a tab for
restoring the defaults... This is stuff in the KM|Net News package
http://www.zope.org:18200/Members/tazzzzz/kmnn

Kevin