[Zope] NESTED IN STATEMENTS AND PASSING VARIABLES in DTML

jpenny@universal-fasteners.com jpenny@universal-fasteners.com
Thu, 20 Jul 2000 14:28:26 -0400


On Thu, Jul 20, 2000 at 12:27:01PM -0500, Theodore Patrick wrote:
> What is the DTML syntax for nested in statements. Here is an example.
> 
> ________________________________________
> EXAMPLE 1: NO VARIABLE PASSING
> 
> GOAL: loop 4 times and with each loop run the category_method and print out
> the results:
> 
> <dtml-in "1,2,3,4">
>     <dtml-in "category_method(id='1')" size=100 start=query_start>
> id=<dtml-var id>&seq=<dtml-var seq>&vid=<dtml-var vid>
>     </dtml-in>
> </dtml-in>
> 
> WORKS!
> 
> ________________________________________
> EXAMPLE 2: VARIABLE PASSING
> 
> GOAL: Loop in the active_category_method and for each row run the
> category_method passing a new 'id' variable and print out the results.
> 
> <dtml-in "active_category_method()">
>     <dtml-in "category_method()" size=100 start=query_start>
> id=<dtml-var id>&seq=<dtml-var seq>&vid=<dtml-var vid>
>     </dtml-in>
> </dtml-in>
> 
> ERROR --> ID is not being passed to "category_method()"
> ________________________________________
> 
> Anyone have a solution out there?
> 
> NOTE: active_category_method and category_method are SQL METHODS. Where 'id'
> is and SQL_VAR for category_method.

This is FAQ material and should be inserted into either the DTML programmer's guide
or the ZSQL Methods guide.  It bites everyone who uses SQL methods eventually.

ZSQL methods do not perform acquisition, but will look at REQUEST, change it
to.
<dtml-in "active_category_method()">
     <dtml-call "REQUEST.set('id', id)">
     <dtml-in "category_method()" size=100 start=query_start>
         id=<dtml-var id>&seq=<dtml-var seq>&vid=<dtml-var vid>
     </dtml-in>
 </dtml-in>

If you have a lot of arguments that need to be captured, you can
build a DTML Method, say setup_category_method_parameters that
has these builds the REQUEST.  Then your dtml can look like:
<dtml-in "active_category_method()">
     <dtml-call setup_category_method_parameters>
     <dtml-in "category_method()" size=100 start=query_start>
         id=<dtml-var id>&seq=<dtml-var seq>&vid=<dtml-var vid>
     </dtml-in>
 </dtml-in>



> 
> Thanks in advance!
> 
> Theodore E. Patrick
> Ishophere.com
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>