[Zope] What's up with calling DTML methods with arguments?
John Morton
jwm@plain.co.nz
Tue, 22 Feb 2000 15:28:49 +1300 (NZDT)
John Morton writes:
> Scenario:
>
> So in my password change report I want to do something like this:
>
> (name and new_password arrive from the request, pwd_format is an
> acquired default)
>
> <dtml-call "sql_change_password(
> user_id=sql_get_user_id(name=name),
> password=encodePassword(password=new_password),
> pwd_format=pwd_format
> )">
Of course this won't work because user_id ends up being a list
reference or something, so I tried this:
<dtml-let name="'jwm'" old_password="'clear'" new_password="'foobar'">
<dtml-let password=new_password>
<dtml-let enc_pass="encodePassword">
<dtml-in "sql_get_user_id(name=name)">
<dtml-call "sql_change_password(user_id=id,password=enc_pass,pwd_format=pwd_format)">
</dtml-in>
</dtml-let>
</dtml-let>
</dtml-let>
...which also doesn't work, resulting in more complaints about
infinite recursion. But this does:
<dtml-let name="'jwm'" old_password="'clear'" new_password="'foobar'">
<dtml-let password=new_password>
<dtml-let enc_pass="encodePassword">
<dtml-in "sql_get_user_id(name=name)">
<dtml-if enc_pass>
<dtml-call "sql_change_password(user_id=id,password=enc_pass,pwd_format=pwd_format)">
</dtml-if>
</dtml-in>
</dtml-let>
</dtml-let>
</dtml-let>
It looks like a side effect of the caching properties of <dtml-if ...>
is that encodePassword gets evaluated at the 'if'. Of course, I
expected it would get evaluated at the <dtml-let> tag, but it appears
that in the first piece of code it gets evalutate in
sql_change_password somehow, so that it's trying to get a value for
password by calling encodePassword which needs a property called
password, so it tries to get a value for password...
Is that what's happening? Should it be?
John.