[Zope] How do I call DTML Method which name is stored in a variable

Evan Simpson evan@4-am.com
Mon, 13 Dec 1999 08:28:05 -0600


Carlos Henrique Bauer wrote:

> On Fri, 10 Dec 1999, you wrote:
> > Carlos Henrique Bauer wrote:
> >
> > > Thanks to Evan Simpson, I learned a method can be called in the following way:
> > >         <dtml-var expr="_.render(FetchObj(_.None, _,fetchStr='hie/dee/hoe').id)">
> > >
> > > Suppose the name of the method is stored in a variable. How do I invoke the
> > > method?
> >
> > Hmm.  Did you mean your variable (let's call it 'v') contains 'hie/dee/hoe', or
> > 'id'?
>
> No. The variable contains the name of the method I want to call and which
> must receive some arguments and return a value, for example:
>
> <dtml-call "REQUEST.set('doc', fetchObj(_.None, _, fetchStr=docPath))">
> <dtml-call "REQUEST.set('metaMethod', _.string.join(_.string.split(_.render(doc.meta_type)[0:])''))">
> <dtml-call "REQUEST.set('metaMethod', _.string.join([metaMethod, 'GetMetaInfo' ], ''))">
>
> If docPath points to a DTMLDocument, metaMethod becomes
> "DTMLDocumentGetMetaInfo".
>
> I'm trying to do something like this (it didn't worked for me):
>
> <dtml-let something="_[metaMethod].(_.None, _,fetchStr=docPath)">
> </dtml-let>

I'm not sure I really follow this, but if you want to fetch a method and then call it, this should work:

<dtml-let something="FetchObj(_.None, _,fetchStr=metaMethod)(_.None, _, args...)">

Cheers,

Evan @ 4-am