[Zope] Passing parameters :python script to Zsql method

facelle@libero.it facelle@libero.it
Fri, 20 Jul 2001 14:52:36 +0200


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=85where=85in" 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=3D"search" method=3D"get">
<p>Please enter the following information:</p>
Code : <input name=3D"code:string"><br>
<input type=3D"submit" value=3D" Search "><br>
</form>


Then I have the following "search" dtml document :

<dtml-call "process_input (code)">
<dtml-call "search_Item (code2=3Dcode1)">


And this is my "process_input" Python script (parameter :code) :

import string
code1 =3D 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=3Dstring>)



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.