[Zope-dev] Need to instantiate zclass in location other than current
Dieter Maurer
dieter@handshake.de
Thu, 18 Apr 2002 23:51:24 +0200
Max Slimmer writes:
> 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.
You locate the destination object with "restrictedTraverse", say "d",
and call the constructor on it:
d.manage_addProduct[<your product name>].<your ZClass constructor>(<its parameters>)
> 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...
I do not understand this question...
Dieter