[Zope] indirect calling of methods with parameters
sam gendler
sgendler@akamai.com
Tue, 27 Mar 2001 16:58:35 -0800
Bernd Worsch wrote:
> <dtml-let method="'ParaMethod(\'lalala\')'">
> <dtml-var "_[method]">
> </dtml-let>
>
I haven't used Zope in a while, but I believe that what you need is
actually a combination of all of the things you have tried. When you use
dtml-var without quotes, the dtml interpreter lookes up the name that you
have specified, and then calls that object if it is callable, otherwise it
calls str() or repr() on it and inserts the results (I believe. I am
guessing what really happens i an object is not callable. It isn't
relevant to this discussion, though). Consequently, that object gets
called without any parameters, since the var tag knows nothing about any
parameter list, and there is obviously not an object named
'method(param1)', just an object named 'method'.
When you use the dtml-var tag with quotation marks inside, the dtml
interpreter assumes the content between the quotes is a python expression,
and executes it directly, within the current context.
Basically, <dtml-var method> is the the equivalent of <dtml-var
name="method">. <dtml-var "method()"> is the equivalent of <dtml-var
expr="method()">
You should be able to say <dtml-var "ParaMethod('lalala')"> to get your
example above working. Don't worry about the _[] syntax, which you don't
need in this instance. Assuming your method name doesn't have any
characters that would be illegal in a python expression (such as '-', or
any other operator), you can call it directly from teh var tag with the
syntax I've shown you. Otherwise, you can use <dtml-var
"_['para-method']('lalala')">
--sam
>
> Thanks
> Bernd
>
> --
>
> -----Bernd Worsch-----------bernd.worsch@frontsite.de--------
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
--
------------------------------------------------
"It feels much better than it ever did,
much more sensitive"
--John Wayne Bobbitt