[Zope-dev] The difference between product Properties and Attributes?

Casey Duncan cduncan@kaivo.com
Tue, 17 Jul 2001 08:59:47 -0600


Richard Ettema wrote:
> 
> Hi,
> 
> I have been looking through the Zope Developers Guide (PollProduct Example)
> and also How-To's to help with creating a Product.
> I am a bit confused whether there is any difference between properties in
> Zope and attributes you create in a Product.

As implemented, properties are stored directly as attributes of an
object.

> I have seen 2 different ways to access attributes created in a product:
> The first is by using _properties and specifying your attribute name/type so
> you can view/edit them on the properties page.

_properties describes the property sheet schema. The values are stored
in attributes.

> The other is to create a dtml page specifically to view/edit the attributes
> you have by calling methods from your product to retrieve/save them.

Generally speaking, it is best from an abstraction sense to use the
built-in API to alter properties, although you can access their values
directly from the attributes.

> Do these 2 ways store/retrieve the attributes in Zope in different ways?  Is
> one approach better than the other?

Using the API is the safest bet for long-term compatibility. This is
true for just about any programming.

> Also...
> I am creating an object based on the Folder object. I only want to allow
> certain objects to be created inside this folder'ish object. Can the objects
> available in the drop-down be restricted like you can when creating ZClasses
> inside Zope?

You can define a class attribute (or method) all_meta_types to return
the meta_types you want to allow in your folderish product. It is a
tuple of dictionaries with 2 keys, name and action. As in:

all_meta_types = ({name:'My Object', action:'manage_addMyObject'}, etc.}

Check out the Zope Developers Guide and ObjectManager.py for more info.

http://www.zope.org/Documentation/ZDG

> 
> Thanks for your help.
> 
> Richard
> 

-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>