Glenn Rogers <zope-list@gacela.demon.co.uk>
To: zope@zope.org Subject: Re:
On Fri, Mar 24, 2000 at 03:28:09PM -0600, Tres Seaver wrote:
Glenn Rogers <zope-list@gacela.demon.co.uk> wrote:
Imagine I have a python extension, with zope id pyFetch
def Fetch (self, href): ...
I want to call this in a manner similar to:
<!--#let call_method="'pyFetch'"--> <!--#in sql-method-returns-href--> <!--#var "_[call_method]( href )"--> <!--#/in--> <!--#/let-->
I don't know what you mean by "python extension" -- is this an ExternalMethod?
Yes. It lives in the zope extensions directory though - blame lack of sleep.
In a DTML method contained/acquired by that folder::
<ul> <dtml-in list_hrefs mapping> <li><dtml-var "this().pyFetch( href )"></li> </dtml-in> </ul>
Problem: In real life, I don't know that I'm calling pyFetch, it could be pyDontFetch or pyGoToSleep etc (the "#let call_method" is in another DTML method and there are a few alternatives). All I know is that it shares the same signature. Works fine if you call it directly.
Is there a better method than the equivalent of
<!--#if "call_method=='pyFetch'"--> <!--#var pyFetch( href )--> <!--#elif "call_method=='pyDontFetch'"--> <!--#var pyDontFetch( href )--> ...
Try this (untested), assuming the name of the method you want to call is stored somehow in the variable 'methodName':: <dtml-let methodToCall="_[ methodName ]"> <dtml-in list_hrefs mapping> <dtml-var "methodToCall( this(), href )"> </dtml-in> </dtml-let> -- ========================================================= Tres Seaver tseaver@palladion.com 713-523-6582 Palladion Software http://www.palladion.com