quick search:
 

Pass arguments directly from the namespace to a ZSQL method

Submitted by: cduncan
Last Edited: 2005-03-10

Category: ZSQL and SQL DA

Average rating is: 4.93 out of 5 (16 ratings)

Description:
As you likely know, ZSQL methods only look in the REQUEST object to find their argument values unless you pass the arguments directly. This can sometimes be inconvenient if your ZSQL method has many arguments some of which might not be coming from REQUEST.

To get around this, you can explicitly pass the namespace variable (_) as the argument to a ZSQL method and it will look in the general namespace for argument values as well.


Source (Text):
<dtml-call expr="myZSQLMethod(_)">

Explanation:
ZSQL methods are internally written to expect a mapping object as their first positional argument, which is expected to contain the argument values. If nothing is passed, the ZSQL Method uses the REQUEST object.

The namespace variable is a mapping object, like REQUEST, so we can simply pass it as the first argument and the ZSQL method will look there for its arguments.


Comments:

How useful! by frabac - 2004-10-14
Thank you for the great suggestion, as I've been banging my head against the problem for quite a long time and found nowhere else any suggestion of the fact.