[Zope] Dynamic Folders in <dtml-in>

Oliver Bleutgen myzope@gmx.net
Wed, 21 May 2003 19:28:23 +0200


Dieter Fischer wrote:
>>Try using
>>
>>_.getitem('your assembled id name')
>>
> 
> 
> I've already tried this, this leads to:
> 
> Error Type: InError
> Error Value: Strings are not allowed as input to the in tag.
> 
> Means, the <dtml-in> doesn't accept strings

First, if I'd do somethink like that I'd call the sql method explictly,
like (first the static version)"

<dtml-in 
"sql.oracle.browse({'var1':REQUEST.form['var1'],'var2':REQUEST.form['var2']})"

yes, it's longer, and it isn't applicable in all situations, but it's 
explicit.

Second, also a matter of taste, I'd prefer <dtml-let ..></dtml-let>  for 
variables, because when REQUEST gets passed around umpteen methods, 
which call each other in sometimes convoluted (dynamic ;)) ways, it 
might be hard to tell why some <dtml-var bla> doesn't render what we 
expected it to render, because it has been injected in the REQUEST much 
earlier and in a galaxy far away. With dtml-let you at least have an 
explicit point where the variable vanishes.

Now, finally, my try to answer your question:
<dtml-let query="oracle"
<dtml-in 
"sql[query].browse({'var1':REQUEST.form['var1'],'var2':REQUEST.form['var2']})"
</dtml-in>
</dtml-let>

or, if you don't want to pass explicitly:

<dtml-in "sql[query].browse(REQUEST})">

(which assumes that the variables you want to use are infact in REQUEST, 
otherwise the mythical "_" should do it)

HTH,
oliver