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
Suppose you have a product (a ZClass) that base class'es a ZCatalog, then only the instance of that will be like a ZCatalog, not its children. My product SiteTrackerProduct is a base class of ZCatalogs and inside the product there are subclasses of the product that then in turn also have ZCatalogs as base class but it doesn't create more than one Vocabulary. Do you have a problem? Are you trying to create a Python Product or a ZClass product?
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
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
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 `------------------>
Ok... I didn't added the two lines into the class, but into the python file. So Zope was unable to find them... Sorry. I'm gonna sleep now. 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 `------------------>
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 `------------------>
Frederic Quin wrote:
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>
right, the latter is used for globally registered classes that can be added everywhere.
By the way, MyObject.manage_addMyObjectForm is well defined in the class like this: manage_addMyObjectForm = DTMLFile( 'dtml/addMyObjectForm', globals() )
Where is this definition? Is the name available in the container class? (Zope apparently thinks not)
So I don't really what's going on...
Frederic
-- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
participants (3)
-
Casey Duncan -
Frederic Quin -
Peter Bengtsson