[Zope] renaming python input params in DTML

Dieter Maurer dieter@handshake.de
Mon, 15 Jan 2001 19:56:56 +0100 (CET)


Lee writes:
 > ...
 > I have a Python method expecting 'text' as a parameter ...
 > ...
 > The Python method, testSQL, returns 'result'.
 > ...
 > <dtml-in expr="REQUEST.form.items()">
 > <dtml-in expr="testSQL(text='<dtml-var sequence-key>x<dtml-var
 > sequence-item>')">
 > <dtml-var result>
 > </dtml-in></dtml-in>
Inside 'expr="..."' you use "_['x']" instead of <dtml-var x>.

As this is a Python expression that needs to be evaluated,
it cannot be in a string. You can use the "%" operator
which takes a format string and an object or tuple as
parameters and formats object/tuple according to the string.

If your Python method contains a "return result",
then there is not magically a "result" variable (and there is
not need for it, too).

Are you sure, you want the nested "dtml-in". Looks very strange.

Thus, you can use:

   <dtml-in expr="REQUEST.form.items()">
     <dtml-var expr="testSQL(text='%sx%s' % (_['sequence-key],_[' sequence-item]))">
   </dtml-in>


Dieter