[Zope] Making a Zope Product question...

Frederic Quin fquin@profile4u.com
Tue, 14 Aug 2001 19:21:23 +0200


Well,
I decided to do like you said.
I put my object type into the meta_types of the container class.

Then I wrote the two lines:
> manage_addMyObjectForm = MyObject.manage_addMyObjectForm
> manage_addMyObject = manage_addMyObjectForm

But Zope can't find this ressource when I try to add an object...
> Cannot locate object at: http://localhost:8080/MyNewObject/manage_addMyObjectForm

When I look at the source of the page, I have:
> <option value="manage_addMyObjectForm">My Object Type</option>
Instead of, usually:
> <option value="manage_addProduct/MyProduct/manage_addMyObjectForm">My Object Type</option>

By the way, MyObject.manage_addMyObjectForm is well defined in the class like this:
manage_addMyObjectForm = DTMLFile( 'dtml/addMyObjectForm', globals() )

So I don't really what's going on...

Frederic


Le Tue, Aug 14, 2001 at 08:46:34AM -0600, Casey Duncan a écrit:
> 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
> `------------------>
>