[Zope] Can't add "date" property to new ZClass

Loren Stafford lstafford@icompression.com
Tue, 12 Oct 1999 11:36:53 -0700


Kevin,

You've just written (below) most of a "How-To: Properties in ZClasses" which
is clearer than anything else I've seen to date. Do you mind if I expand it
into a formal "How-To"?

There's just a couple more things I don't understand, but would want to
explain in a How-To document:

1. A ZClass can have more than one property sheet. But why would you want to
use that capability? Different permissions? Displayed under different
circumstances? ...? ...examples?

2. When instantiating a ZClass, the Factory errors if the properties are not
defined. Should it do that? Shouldn't it handle undefined properties? (Is
that what Michel meant when he wrote "In fact, [Zope] should be smarter for
instances also and just assume a sane value (like calling DateTime() with no
arguments, which returns 'now')."

-- Thanks
-- Loren

> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Kevin
> Dangoor
> Sent: Monday, October 11, 1999 17:26
> To: Loren Stafford; Dr. Ross Lazarus; zope@zope.org
> Subject: Re: [Zope] Can't add "date" property to new ZClass
>
>
> -----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
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://www.zope.org/mailman/listinfo/zope
>
> (Related lists - please, no cross posts or HTML encoding!
>
> To receive general Zope announcements, see:
> http://www.zope.org/mailman/listinfo/zope-announce
>
> For developer-specific issues, zope-dev@zope.org -
> http://www.zope.org/mailman/listinfo/zope-dev )
>