[Zope] - YASQ (yet another stupid question)

Amos Latteier amos@aracnet.com
Wed, 23 Dec 1998 13:48:45 -0800


At 02:55 PM 12/23/98 -0600, Chad Fowler wrote:

>Say you have an external method, or a SQL Method that accepts a
>parameter.
>You want that parameter to be dynamic (possibly based on a field from a
>DB).
>How can you pass a dynamic parameter to a method from within DTML?
>
>i.e.:
><!--#in expr="getSpam(cost=<!--#var spamcost-->)"-->

What you've got is basically right, it's just a question of syntax. In
general you can refer to variables defined in the REQUEST by name:

<!--#in expr="getSpam(spamcost)"-->

Sometimes there are problems with this, if for example you want access to
special sequence-item variable. In these cases you can lookup variables in
the namespace mapping object (whose unpronounceable name is written '_')
like so:

<!--#var expr="getSpam(_['spamcost'])"-->

For an example of how to use this namespace feature to include random bits
of content see:

http://www.zope.org/Documentation/HowTo/RandomContent

You should also check out the DTML Users Guide which spells out pretty well
how to use DTML:

http://www.digicool.com/site/Principia/DTML.html

Hope this helps. And BTW, DTML *is* complex; your question is not stupid.

-Amos