[Zope] Can't add "date" property to new ZClass
Kevin Dangoor
kid@kendermedia.com
Mon, 11 Oct 1999 20:25:54 -0400
-----Original Message-----
From: Loren Stafford <lstafford@icompression.com>
To: Dr. Ross Lazarus <rossl@med.usyd.edu.au>; zope@zope.org <zope@zope.org>
Date: Monday, October 11, 1999 7:15 PM
Subject: RE: [Zope] Can't add "date" property to new ZClass
>After adding the report to the Collector, I went back to Zope to see what
>would happen if I just put in a dummy value. It accepts it and goes on it's
>merry way. So then I finish up the class, and modify the PDFClass_addForm
>method to prompt for the class properties and the file ("File" is one of
the
>base classes). The date field looks like this: <input type=text
>name="pub_date:date"> (You'd think ZClass could automatically put the
>properties on the _addForm, too.)
When you add a ZClass, Zope creates your ZClass_add and ZClass_addForm from
simple templates. After they have been created, you're on your own.
>Now it's time to try to create a test instance of the class. I get the
>_addForm, fill in all the fields and submit. Success! ...well, almost.
>There's a date in the new instance, but it's the dummy date I put in the
>class, not the date I specified for the instance.
>
>So I tried changing the form field to: <input type=text name="pub_date">
(no
>type override) ...same result.
>
>What's even weirder is that the method that displays objects with the "PDF
>File" meta-type created by this class doesn't seem to get any date at all
>from the object -- it shows up as empty -- neither the dummy class date nor
>the instance date I put in.
Basically, the ZClass_add method that is created automatically is just
enough to create a ZClass instance. It is not enough to actually populate
the ZClass. Why? Because at the time the ZClass is created, it doesn't have
any propertysheets to populate. Having the ZClass_add automatically change
when a propertysheet is added is not necessarily desirable...
Once you've created a propertysheet, and possibly updated the ZClass_addForm
method to include additional fields, you should go into the constructor
(ZClass_add). In there, there is a commented section that you should
uncomment that includes the line;
<dtml-call "propertysheets.Basic.manage_changeProperties(REQUEST)">
Change this line from Basic to whatever the name of your propertysheet is.
If your ZClass is CatalogAware, you will want to add
<dtml-call reindex_object>
immediately after the manage_changeProperties line.
Kevin