Passing parameters :python script to Zsql method
Hi everybody, I know this is a ricurrent newbie problem, and I have been searching the ML archives, but yet I could not solve it. How can I pass a parameter from a python script to a Zsql method ? I want to perform a very basic multiple value query on a database through the sql "select where in" command. I would split the REQUEST into a list, and then pass it to a Zsql method. I have the following Dtml document (named "form_itemSearch") : <form action="search" method="get"> <p>Please enter the following information:</p> Code : <input name="code:string"><br> <input type="submit" value=" Search "><br> </form> Then I have the following "search" dtml document : <dtml-call "process_input (code)"> <dtml-call "search_Item (code2=code1)"> And this is my "process_input" Python script (parameter :code) : import string code1 = string.split(code) return code1 And my "search_Item" zsql method (argument: code2 )is : select * from items where code_item in (<dtml-sqlvar code2 type=string>) If I call the first "form_itemSearch" from the web, I get the following error : Zope has encountered an error while publishing this resource. Error Type: NameError Error Value: code1 Troubleshooting Suggestions * This resource may be trying to reference a nonexistent object or variable code1. * The URL may be incorrect. * The parameters passed to this resource may be incorrect. * A resource that this resource relies on may be encountering an error. For more detailed information about the error, please refer to the HTML source for this page. If the error persists please contact the site maintainer. Thank you for your patience. ----------------------------------- Where is my mistake ? Thanks in advance. Fabrizio C.
facelle@libero.it writes:
.... I have the following Dtml document (named "form_itemSearch") :
<form action="search" method="get"> <p>Please enter the following information:</p> Code : <input name="code:string"><br> <input type="submit" value=" Search "><br> </form>
Then I have the following "search" dtml document :
<dtml-call "process_input (code)"> <dtml-call "search_Item (code2=code1)"> You discard the output of "process_input". Instead, you want use it as "code1":
<dtml-in "search_Item(code2=process_input(code))"> do something with search result rows </dtml-in>
.... And my "search_Item" zsql method (argument: code2 )is :
select * from items where code_item in (<dtml-sqlvar code2 type=string>) Your "code2" is not a string, is it.
Use: where <dtml-sqltest code2 column=code_item multiple> Dieter
participants (2)
-
Dieter Maurer -
facelle@libero.it