[Zope] NESTED IN STATEMENTS AND PASSING VARIABLES in DTML
Theodore Patrick
tpatrick@IndigoNetworks.com
Thu, 20 Jul 2000 13:34:30 -0500
THANKS A TON!!!
I just found that the following solutions works also:
I think the only difference is the id is evaluated in the namespace variable
before invoking the SQL_METHOD
<dtml-in "active_category_method()">
<dtml-in "category_method(id=(_['id']))" size=100 start=query_start>
id=<dtml-var id>&seq=<dtml-var seq>&vid=<dtml-var vid>
</dtml-in>
</dtml-in>
or
<dtml-in "1,2,323,23,23">
<dtml-in "category_method(id=(_['sequence_item']))" size=100
start=query_start>
id=<dtml-var id>&seq=<dtml-var seq>&vid=<dtml-var vid>
</dtml-in>
</dtml-in>
------------------------------------
Your point on the SQL_METHODS is a good one! I had no idea!
Theodore E. Patrick
-----Original Message-----
From: jpenny@universal-fasteners.com
[mailto:jpenny@universal-fasteners.com]
Sent: Thursday, July 20, 2000 1:28 PM
To: Theodore Patrick
Cc: zope@zope.org
Subject: Re: [Zope] NESTED IN STATEMENTS AND PASSING VARIABLES in DTML
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 )
>