[Zope] how to create an object programmaticaly
Robert Rottermann
robert@redcor.ch
Sun, 17 Feb 2002 18:33:57 +0100
Hoi Daniel,
there is no difference really. You have to call manage_addProduct.... on the
"object" in which you want the new instance to be created.
In your example the "object" is context.
So what you have to do is acquire the target object on which you then call
manage_addProduct.....
You can do that like this:
folder2 = getattr(context, 'folder2')
target = folder2.subfolder2.subfolder3
target.manage_add....
you could do that in one step
getattr(context, 'folder2').folder2.subfolder2.subfolder3.manage_add....
Robert
----- Original Message -----
From: "Daniel Meier" <info@manifakt.com>
To: <zope@zope.org>
Sent: Sunday, February 17, 2002 3:52 PM
Subject: [Zope] how to create an object programmaticaly
> hi there
>
> I'm trying to create an object in a python script, like this it works:
>
> context.manage_addProduct['ChernobylObjects'].<my
> zclass>.createInObjectManager('myId', container.REQUEST )
>
> the object is created in the same folder as I call the script.
>
> but now I'd like to create a new object in another folder (not in a
parent,
> not in a sibbling an not in a subfolder)
>
> like this:
>
> /folder1/subfolder (I'm here)
> /folder2/subfolder2/subfolder3 (that's where I'd like to create my new
> object)
>
> I have the destination path for my object in a string variable. this path
> changes constantly (for some special apllication reasons).
>
> how can I create my object with the path for it in a string variable?
>
>
> regards
>
> daniel
>
>
> _______________________________________________
> 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 )
>