[Zope] Instance within Instance
Dieter Maurer
dieter@handshake.de
Mon, 27 Nov 2000 23:40:47 +0100 (CET)
Daryl Stultz writes:
> I have a product folder called "TestClass" with 2 ZClasses: class1 and
> class2.
> The following is an exerpt from the class1 constructor:
>
> <dtml-with "class1.createInObjectManager(REQUEST['id'], REQUEST)">
> <dtml-call "REQUEST.set('id', 'myClass2')">
> <dtml-call "class2_add(_.None, _, NoRedir=1)">
> </dtml-with>
>
> I want class2 to be created INSIDE of the class 1 instance. Instead,
> class2 (always with an id of "myClass2") is created at the same level as
> the class1 instance. How do I change the namespace to get the class2
> instance inside class1?
You should look at the source of your "class2_add",
especially the constructor that creates the object.
I expect, that you use "class2.createInObjectManager"
to create your "class2" instance.
"C.createInObjectManager" usually uses "C.aq_parent" to
determine the object manager where the new C instance
should be created (unless it has a "Destination" attribute).
This should be your "class1" instance "instance1", more
precisely, an acquisition wrapper for it.
There are two possibilities:
1. for reasons, I do not understand, "class2.aq_parent"
is not "instance1"
2. it is "instance1", but "instance1" does not have
a "_setObject" method, i.e. "class1" is not derived
from ObjectManager.
Dieter