[Zope] Making a Zope Product question...

Casey Duncan cduncan@kaivo.com
Tue, 14 Aug 2001 08:46:34 -0600


Frederic Quin wrote:
> 
> Hi all,
> I am trying to create a Zope Product...
> I have a first base Class and other classes.
> The other classes must be accessible and instanciate only from instances of the first base class.
> For example, Vocabulary objects can be everywhere in the tree.
> I would like Vocabulary objects to be created only inside ZCatalogs...
> 
> I don't know how to do that...
> 
> Thanks,
> 
> Frederic Quin
> 

First, don't register the class that you don't want added everywhere in
the __init__.py. Then define a class attribute on the container called
"meta_types" which is a tuple of dictionaries describing the extra
metatypes(s) you want available in your container objects. If these are
the only objects that should be added to the containers, then use
"all_meta_types" instead. Define this attribute like so:

meta_types = (
    {'name':'My Object Type', 'action':'manage_addMyObjectForm',
'permission':'Add My Objects'},
)

The permission is optional. You will need to define (or at least
reference) manage_addMyObjectForm (and the action it specifies) in your
class definition. Usually, I define these in a separate module (along
with the actual MyObject class) and add something like this to the
container class:

manage_addMyObjectForm = MyObject.manage_addMyObjectForm
manage_addMyObject = manage_addMyObjectForm

if you are using ClassSecurityInfo, you should also add:

security.declareProtected('Add My Objects', 'manage_addMyObjectForm',
'manage_addMyObject')

Where 'Add My Objects' is the name of the permission a user should have
in order to add them.

For more info see: http://www.zope.org/Documentation/ZDG

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