passing object from dtml to python script
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> -- 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.
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)"> On Mon, May 14, 2001 at 04:11:41PM -0700, Luby Liao wrote:
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>
-- 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.
_______________________________________________ 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 )
-- ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres@corrada.com Internet Programming http://www.mamey.com ------------------------------------------------------
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.
I've been having problems with Xron firing off reliably but now I've fixed it. I'm not sure exactly what fixed it but here's what I did. 1 Reinstalled Xron and restarted Zope (don't think this did it). 2. Made sure all my Xron Methods had the security needed by selecting manager/owner (Don't think it was this either) 3. My Xron method called External Methods , so I set the External Method to have an Anonymous / View in it's security tab. (It may have been this) 4. My external method, although it had a dtml-try/except clause in it was failing. I removed the bits that failed completely. (it could have been this too!) 5. I repeatedly hit Update in the Schedule ( random clicks sometimes fixes stuff doesn't it?) I also did loads of other stuff but I think it was one of the above... If you've been having these problems I hope this helps Good luck tom -- tom smith | tom@othermedia.com http://www.othermedia.com/blog tel 020 8541 5355 | fax 020 8541 5507 11 penrhyn road, kingston-upon-thames, london KT1 2BZ
Hi Luby, I think you are misunderstanding the purpose of HTML forms (forgive my presumption!). When you use dtml-call you will get no results back from the call, thus you are seeing ACTION="". ACTION should be followed by a valid URL to the handler that will process the form. I have not probed into your script too deeply but it seems that you can use the firstname, lastname variables to pass to the handler script and then use emailSearch again in the handler. That way you avoid passing x, which you really cannot pass using the HTTP protocol anyhow. On Thu, May 17, 2001 at 09:29:23AM -0700, Luby Liao wrote:
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.
_______________________________________________ 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 )
-- ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres@corrada.com Internet Programming http://www.mamey.com ------------------------------------------------------
Andres, thank you for taking an interest in my question. After reading Zopebook, the chapter on 'Advanced Zope Scripting', I decided that what I want does not auto-magically happen, yet. The application I have in mind is a shopping-cart-like program in which we continue to go from one form to another form, keeping all that have been entered plus the result of sql queries, typically using hidden fields. I have written a python script to flatten REQUEST.form.items() into hidden INPUT html element to propagate the information to the next form. I also find pluggable brains for ZSQL methods helpful. Thank you again for your help. cheers, Luby
Hi Luby,
I think you are misunderstanding the purpose of HTML forms (forgive my presumption!). When you use dtml-call you will get no results back from the call, thus you are seeing ACTION="". ACTION should be followed by a valid URL to the handler that will process the form.
I have not probed into your script too deeply but it seems that you can use the firstname, lastname variables to pass to the handler script and then use emailSearch again in the handler. That way you avoid passing x, which you really cannot pass using the HTTP protocol anyhow.
On Thu, May 17, 2001 at 09:29:23AM -0700, Luby Liao wrote:
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.
_______________________________________________ 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 )
-- ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres@corrada.com Internet Programming http://www.mamey.com ------------------------------------------------------
participants (3)
-
andres@corrada.com -
Luby Liao -
tom smith