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

Mick vsl6@paradise.net.nz
Tue, 17 Jul 2001 23:29:17 +1200


I have only made a few python products, so my answers may not be entirely
well established ...

> -----Original Message-----
> From: zope-dev-admin@zope.org [mailto:zope-dev-admin@zope.org]On Behalf
> Of Richard Ettema
> Sent: Tuesday, July 17, 2001 10:27 PM
> To: zope-dev@zope.org
> Subject: [Zope-dev] The difference between product Properties and
> Attributes?
>
>
> 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.
> 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.

They seem to be one and the same when looked at from some angles, I should
add to this mix that adding something as an explicit property, i.e. in the
_properties dictionary, also makes it an attribute of the object in the ZDOM
sense, a very useful thing to discover.  As for managing the properties, one
behaviour you get for free by making some of you class attributes properties
is the use of manage_changeProperties(REQUEST), which looks through you
REQUEST object for name value pairs that match your properties.  Nice when
working with forms input.


> The other is to create a dtml page specifically to view/edit the
> attributes

This is all very similar except that you have to explicitly load your class
attributes in some action method you have written.  However I am guessing
you may benfit from another reason below.


> you have by calling methods from your product to retrieve/save them.
> Do these 2 ways store/retrieve the attributes in Zope in
> different ways?

I don't think so, my guess is that different Zope methods will look for
_properties dictionaries to see what class attributes it would like to play
with.  I'm sure Dieter or Chris or someone has a deeper interpretations of
this.

Tou said below you are deriving from Folder ... this is the really nice
part.  If you are indeed subclassing(or mixing in) Folder, then you get the
manage_main for free  eg : when defining your manage options  :

manage_options = (
(
	{'label':'Custom','action':'mange_customEditForm',}
) + Folder.Folder.manage_options

and for _properties you can add the attributes of you class that you want to
appear on the properties_manage tab, eg :

_properties = (
	{'id':'myname','type':'string','mode':'w'},
)

and in def __init__(self):
	self.myname = "Mick"

> Is
> one approach better than the other?
> 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?

>From what I understand this is a permissions thing.  You just set the
permissions of people to be able to add only certain objects.  There is
perhaps a way of hooking into the objectmanager of the folder to force it to
only allow one to add certain metatypes.


hope some of this helps
Mick




>
> Thanks for your help.
>
> Richard
>
>
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )