[Zope] Add a property with a class constructor
Dieter Maurer
dieter@handshake.de
Wed, 25 Apr 2001 18:52:59 +0200 (CEST)
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