[Zope] passing a zope <dtml-in...> list element to a sql method

J. Cameron Cooper jccooper at jcameroncooper.com
Mon Sep 29 22:22:37 EDT 2003


>      <dtml-in category prefix=test>  <dtml-comment>this is the 
> list</dtml-comment>
>
>      <dtml-call name="sql_delete_a_category(trash='<dtml-var 
> test_item>')">
>        <dtml-var test_item><br>  <dtml-comment>used to verify items 
> are looping</dtml-comment>
>      </dtml-in>

The nested tag nature of DTML seems to have confused you as to how it 
actually works. One cannot put a DTML tag inside a DTML tag, though you 
can put DTML tags inside HTML tags. It's an easy mistake to make in 
clear languages, and especially in DTML.

Think of it as a two-pass process. Zope does the first pass and renders 
everything that looks like DTML. The output then should be HTML, which 
is given to the browser for a second pass. Note that there's no room 
here for a DTML tag inside a DTML tag to be rendered such that its 
results can be used in a DTML tag.

Or imagine that a DTML tag is a Python print statement. You can't do:

print "this is the contents of variable print a"

when you mean

print "this is the contents of variable " + a


And for an entry to the ZPT v. DTML debate, it's a lot clearer what to 
do in ZPT:

<span tal:repeat="test somewhere/category">
  <tal:call tal:define="dummy 
python:sql_delete_a_category(trash=repeat.test)" />
  <span tal:replace="repeat/test" />
</span>


I refer you also to the threads (one old, one new)::

"rendered method in dtml document"
and
"testing with dtml-if"

             --jcc

-- 
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."





More information about the Zope mailing list