[Zope] passing object from dtml to python script
Luby Liao
liao@acusd.edu
Thu, 17 May 2001 09:29:23 -0700 (PDT)
I posted the following question on 5-14-2001. I got a prompt response
from Andres (Thank you, Andres). I tried his suggestions (see below)
with many variations without success. With some variations, e.g.,
ACTION="<dtml-call complete_or_not(x)>" (line 9)
there are no errors. Yet view source shows
ACTION=""
and reading the log from var/Z2.log shows that the python script is
never called when the form is submitted.
Thank you in advance for your thoughts. cheers, Luby
1. My question
Is it possible to pass objects in a dtml, such as a row of the result
set of a sql query, into a python script used as a form handler?
As an example, on line 9, 'complete_or_not' is a python script with
one argument. I would like to pass an object x (line 2) into the
script. But the syntax of line 9 is incorrect. I could effectively
pass x in using hidden fields. But I hope I can avoid that. Any help
is greatly appreciated. cheers, Luby
1 <dtml-if email>
2 <dtml-let x=emailSearch>
3 <dtml-if "_.len(x)==1">
4 <dtml-in x>
5 If you are <dtml-var firstname> <dtml-var lastname>, please
6 proceed to complete the registration, by clicking the
7 'complete' button. Otherwise, click the 'not me'
8 button.
9 <FORM METHOD="POST" ACTION="complete_or_not(x)>" NAME="complete" onSubmit="return verifyInput()">
10 <TABLE border="0" cellpadding="0"><TR><TD align="right">
11 <INPUT TYPE="submit" NAME="complete" VALUE="Complete"></TD><TD align="right">
12 <INPUT TYPE="submit" NAME="not_me" VALUE="Not Me"></TD></TR>
13 </TABLE>
14 </FORM>
15 </dtml-in>
16 </dtml-if>
17 </dtml-let>
18 </dtml-if>
2. Andres's solution
Yes its possible to pass objects to scripts you call in dtml.
One way to fix your syntax error is to write:
<form method="post" action="<dtml-var "complete_or_not(x)" url>" ... >
But that will just create the url where your user will go once they click
their button.
If you want to avoid passing hidden fields take a look at the
CoreSessionTracking product.
In general you can call a script with something like:
<dtml-var "someScrip(mySpecialObject=x)">
or
<dtml-call "someScriptWhoseSideEffectsIDoNotWantToSee(mySpecialObject=x)">
--
Luby Liao, Department of Math/CS, University of San Diego, San Diego, CA 92110
(619)260-4021(O), (619)452-7644(H), (619)260-4293(fax)
'Twas brillig, and the slithy toves Did gyre and gimble in the wabe:
All mimsy were the borogroves And the mome raths outgrabe -- L.C.