[Zope] passing arguments from dtml methods to SQL methods

Allen Wallis allen@rrsg.ee.uct.ac.za
Wed, 29 Mar 2000 11:47:13 +0200


Hi,
Thanks for previous help on the namespace variable '_', much
appreciated!

I have another problem though, how does one pass parameters between DTML
methods, and from dtml methods to ZSQL methods?

I have a DTML method "getSearchResults" that gets called when a form is
posted using
<FORM... action="getSearchResults">
<INPUT NAME="fname"
</FORM>
The method gets called and magically the form fields like fname
described in the above form are accessible from the dtml method, so I
can do <dtml-var fname> and there's the input from the user. (I still
don't fully understand how that bit of black magic works...)

Ok, then I have a ZSQL method with fname as an argument, and again, when
my dtml method calls the zsql method, that variable fname can be
accessed using <dtml-var fname> in the SQL query. While maybe I don't
completely understand what's happening, I can still use it. The problem
now is, my ZSQL method needs to have an argument "tablename" that it can
use so that a different table can be selected, however, this tablename
is not under the user's direct control. It gets set according to some
choices that the user makes along the way. I would hence need to
"declare" it in the dtml method "getSearchResults", initialise it, and
pass it to the ZSQL method so that the ZSQL method can use it. I tried
doing the following: (suppose the ZMYSQL method's id is "searchMySQL").
in the dtml method:
    <dtml-if expr="whatever">
       <dtml-var name="getSearchResults(fname=fname,
tablename='suppname')">
    </dtml-if>
So that didn't work, but maybe it describes what I'm trying to do - that
is, fname exists and is initialised from the user's form input, but
I want to create the variable tablename, and pass it to another method
(or just create in the namespace space so that it's accessible to other
methods).

Sorry to be so long-winded, trying my best to describe things with my
very limited knowledge of zope/python.

Many thanks
Allen