[Zope] Choose where to create a ZClass instance with EM

Dieter Maurer dieter@handshake.de
Thu, 17 Aug 2000 20:45:44 +0200 (CEST)


Francois-Regis CHALAOUX writes:
 > Hi,
 > 
 > When I create a ZClass instance from an external Method I create by default
 > the instance in the same place where is located my external method (see the
 > code below).
 > 
 > How to select a different place in my script where will be create the ZClass ?
 > 
 > ====
 > Code
 > ====
 > 
 > def addZClass(self,id,data):
 >    newob=self.Control.Panel.Products.MyProduct.MyClass(id)
 >    newob.id=id
 >    newob.propertysheets.Properties.manage_changeProperties(data)
 >    self._setObject(id,newob)
Here, you decide that the new object is placed into "self".

Use "self.whereever._setObject(id,newob)"
to place it in "whereever".
Of cause, "whereever" must be acquired by "self" for this to work.

You would use "getattr(self,wherever)", if "whereever" is not
a constant name but an expression, e.g. passed in via a parameter.



Dieter