Daryl Stultz wrote:
Tim Cook wrote:
The problem here is that even though you set REQUEST, it is a string. You need to be in the context of the parent _object_. You should try <dtml-with "_.getitem(parent_id)">.
What's happening now is that my class2 is getting created at the same level as class1. What I want is class2 to be INSIDE class1. So I don't want the parent context, I want the class1 context. <dtml-with "_.getitem(myClass1_id)"> gets me the class2 instance at the same level...
How can I get a new context of the newly created class1 instance?
This dtml-with should be in a DTML Method, not in your constructor. As I recall you are trying to construct the class2 from inside the class1 constructor. There may be a way to get that to work, I don't know. But if you use a DTML Method like this: ----------- add_myclass ----------------------- This method contains a form to gather all of your required property values. It should POST to add_myclassProcessor. ----------------------------------------------- ----------- add_myclassProcessor ------------------ ... <dtml-call expr="REQUEST.set('id', 'MyClass1ID')"> ... <dtml-with "manage_addProduct['MyCoolProduct']"> <dtml-call expr="Class1_add(_.None, _, NoRedir=1)"> </dtml-with MyCoolProduct> <dtml-with "_.getitem(MyClass1ID)"> ... <dtml-call expr="REQUEST.set('id', 'MyClass2ID')"> ... <dtml-with "manage_addProduct['MyCoolProduct']"> <dtml-call expr="Class2_add(_.None, _, NoRedir=1)"> </dtml-with MyCoolProduct> </dtml-with MyClass1ID > --------------------------------------------------- I guarantee that you will end up with a folder MyClass1ID that contains MyClass2ID. This may not be the most spectacular Zope code. There are alot of things that Zope can do that I don't know yet. But this works and it's readable when indented properly. Maybe, someone else can telly you a REALLY COOL way to get it done from inside the Class1 constructor. But if you want it to work now. Try this way. <s> HTH, -- Tim Cook, President -- Free Practice Management,Inc. | http://FreePM.com Office: (901) 884-4126 Censorship: The reaction of the ignorant to freedom.