[Zope-dev] traversing from zope product

Vincenzo Di Somma e.disomma@icube.it
Wed, 22 Aug 2001 12:00:38 +0200


Hi all,

in our zope product (a folderish class) we want to call one of its 
contained methods (like a dtml-method, for example). We also want to 
decide which method (of all dtml-methods contained in the folderish 
item) at run-time... We tried using eval('self.' + method_name) and it 
works... The problem is it can't refer any other object in the same 
folder (more in general it can't traverse the zope tree)... what can we do?

An example: in our "ff" folderish item there is a "mh" mailhost item and 
a "dm" dtml-method. We call "dm" from one of our "ff" methods (say 
"ff.mm") using eval("self.dm"). The result is that "dm" is correctly 
called but it won't find its "mh" mailhost (needed to send the mail).

1) Our code:

class ourclass (Folder)

def ourmethod(self, ...):
	method_name=...  #will be "dm" at run-time
	parameters=...	 #parameters for "dm"
	eval("self." + method_name)(parameters=parameters)



2) Zope tree

+-ff
   |
   +-dm
   |
   +-mh


-- 
Vincenzo Di Somma - Responsabile Ricerca e Sviluppo - Icube S.r.l.
Sede:   Via Ridolfi 15 - 56124 Pisa (PI), Italia
E-mail: e.disomma@icube.it              WWW: www.icube.it
Tel:    (+39) 050 97 02 07              Fax: (+39) 050 31 36 588