[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Advanced Zope Scripting
Thu, 26 Sep 2002 17:29:45 -0400
A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/ScriptingZope.stx#3-25
If the *updateInfo* script requires parameters, you must either
choose a name for the DTML namespace binding (see Binding
Variables below) so that the parameters will be looked up in the
namespace, or you must pass the parameters in an expression,
<dtml-call expr="updateInfo(color='brown', pattern='spotted')">
% Anonymous User - Sep. 4, 2002 12:34 pm:
Calling a script with hardcoded values is pretty useless in the real world. It would be great to have an
example that shows how to grab variables from the namespace and insert them into the parameter list in this
% Anonymous User - Sep. 20, 2002 7:08 am:
I'm not sure if the following snippet does the job:
<dtml-call expr="updateInfo(color='<dtml-var hair_color>', pattern='<dtml-var hair_pattern>')">
% Anonymous User - Sep. 26, 2002 5:27 pm:
This does work:
<dtml-var expr="make_user_list(users, abs_url)">
<dtml-call expr="make_user_list(users, abs_url)">
where users is a sql "dtml-in" call result parameter.
abs_url was created like this:
in the above example, anything within the "" will be evaluated, so there is no need to specify "dtml-var".
With sql calls this generally works:
<dtml-in expr="some_sql_method(color=_['hair_color'], pattern=_['hair_pattern'])
% Anonymous User - Sep. 26, 2002 5:29 pm:
also, the parameters are grabbed from the context where the method was called.
So, anywhere that <dtml-var hair_color> is valid, you can call a method that expects a hair_color parameter
just with its name:
<dtml-call some_method> and it will find the parameters.