[Zope] Variable substitution in an object name

Dieter Maurer dieter@handshake.de
Sat, 16 Jun 2001 16:48:39 +0200 (CEST)


Please do not post HTML messages!

Lou Scalpati writes:
 > I can substitute a property name for the base of an object call with:
 > 
 > <dtml-var expr="_[wrap].index_html(_.None,_)">
 >     where wrap is a property that refers the name of an object
 > 
 > But I have not been able to figure out how to use a variable to substitute the method (in this case index_html but could be index_xml or index_wap) 
You call for "Computed Attribute Access".
You can use "getattr" for this. Its a method of "_".
Thus, you would use:

      <dtml-var expr="_.getattr(_.getitem(wrap),*YOUR METHOD EXPRESSION*)(_.None,_)>

e.g.

      <dtml-var expr="_.getattr(_.getitem(wrap),'index_html')(_.None,_)>


Dieter