On 4/17/02 4:49 PM, "Max Slimmer" <[EMAIL PROTECTED]> wrote:

> I have created a zclass and want to create a new instance of this class and
> have it be child of some other know object in the tree.
> Given that we know the path (url) to the new prospective parent how do we do
> this.

I do this a lot, with my own custom add in screens that add objects in
special locations.  I have it working like this in a python script::

target = context.content.documents       # folder to put the document in

### Create a new instance.
new_item = target.manage_addProduct[
    'MyProduct'].MyZClass.createInObjectManager(new_id, REQUEST)
## other operations on the new item
new_item.setTitle('Rockabilly Bob')

> A second question. I need to manage lists of these zobjects within other
> instances of the same, is there a reason to store the url vs the object(s).
> I have has some problems getting back a string repr of the object "<instance
> of .."
> instead of the object?  It would probably be better for me (the code) to
> store objects thus not need to get the object each time I want to call a
> method...

You'll want to store the path to the object.  Making other 'hard' references
to a persistent object in Zope is still a scary proposition.

Jeffrey P Shell 

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to