Re: [Zope] Add a property with a class constructor
=?iso-8859-1?q?Herv=E9=20Richard?= writes:
In a foder i can write a dtml-method like this, but from the constructor ?
<dtml-with "PARENTS[0]"> ... You replace "PARENTS[0]" with the newly created object.
Your object must be a PropertyManager for the "manage_addProperty" to be available. Otherwise, you may need to add properties to a property sheet. See embedded Zope Online Help --> Zope Help --> API Reference --> * whether PropertySheets support adding new preperties. Dieter
Hi Dieter, thank you for your help but something is wrong with me : Le Samedi 14 Avril 2001 20:21, Dieter Maurer a �crit :
Herve Richard writes:
In a foder i can write a dtml-method like this, but from the constructor ?
<dtml-with "PARENTS[0]"> ...
You replace "PARENTS[0]" with the newly created object
Your object must be a PropertyManager for the "manage_addProperty" to be available.
Ok, i understand the scheme
Otherwise, you may need to add properties to a property sheet. See embedded Zope Online Help --> Zope Help --> API Reference --> *
Yes, i try, but i don't find all help i need : for example when you create a new class, the default script class constructor use the function CreateInObjectManager(...) : <dtml-with "TotoClass.createInObjectManager(REQUEST['id'], REQUEST)"> But when i read the online help (Zope 2.3) i see : ObjectManager An ObjectManager contains other Zope objects. The contained objects are Object Manager Items. Creating Objects in an ObjectManager To create an object inside an object manager use manage_addProduct: self.manage_addProduct['OFSP'].manage_addFolder(id, title) In DTML this would be: <dtml-call"manage_addProduct['OFSP'].manage_addFolder(id,title)"> ..... Probably something is missing to me, it seem like 2 methods to do the same thing : - createInObjectManager(..) - manage_addProduct['OFSP'].manage_addFolder(id, title) where is the difference ? I don't find the doc which synthesize all the ways ! any URL ? Thank's a lot
whether PropertySheets support adding new preperties.
(
Otherwise, you may need to add properties to a property sheet. In this case i think it is not possible because i want to add a different number of properties each time i create a new object. )
Dieter
-- Herve RICHARD INRA - Biometrie tel: 04 32 72 21 79 AgroParc Prof. email: Herve.Richard@avignon.inra.fr 84914 AVIGNON cedex 9 Priv. email: rv.richard@oreka.com
Hi Richard Herv=?iso-8859-1?Q?=E9?= Richard writes:
... for example when you create a new class, the default script class constructor use the function CreateInObjectManager(...) :
<dtml-with "TotoClass.createInObjectManager(REQUEST['id'], REQUEST)">
But when i read the online help (Zope 2.3) i see :
ObjectManager
An ObjectManager contains other Zope objects. The contained objects are Object Manager Items.
Creating Objects in an ObjectManager
To create an object inside an object manager use manage_addProduct:
self.manage_addProduct['OFSP'].manage_addFolder(id, title)
In DTML this would be:
<dtml-call"manage_addProduct['OFSP'].manage_addFolder(id,title)">
.....
Probably something is missing to me, it seem like 2 methods to do the same thing : - createInObjectManager(..) - manage_addProduct['OFSP'].manage_addFolder(id, title) With "createInObjectManager" you are one step further:
You are already in the context of the correct product, such that you can access your class. This is not yet the case when you use "manage_addProduct....". In this context, your class is not yet known. Only "manage_addProduct" is available, but it is able to bring you in the context of any product. This way, you can access the constructors defined by a product and use them to create product related objects.
Otherwise, you may need to add properties to a property sheet. In this case i think it is not possible because i want to add a different number of properties each time i create a new object. That should not be a problem. Of course, you need an application specific way to determine which properties you need. Once you know, which one, you can simply create them and give them values.
Dieter
participants (2)
-
Dieter Maurer -
Hervé Richard