[Zope] Pass Arguments to ZSQL Method from Python Script
Grace, Mark
Mark.Grace@imd.ch
Mon, 3 Mar 2003 10:25:11 +0100
Hi All,
Warning, newbie question coming up!
I have a form (DTML Document):
-----------------------
<dtml-var standard_html_header>
<h3>Add Employee:</h3>
<form action="addEmployeeAction">
id: <input type="text" name="emp_id:int"><br>
first: <input type="text" name="first"><br>
last: <input type="text" name="last"><br>
salary: <input type="text" name="salary:float"><br>
<input type="submit">
</form>
<dtml-var standard_html_footer>
----------------------
That submits to the following Python Script:
----------------------
##parameters=emp_id, first, last, salary
rec = context.Queries.insertEmployeeQuery(emp_id=emp_id, first=first,
last=last, salary=salary)
print "-" * 80
print "Employee Added:"
print "-" * 80
print """%i
%s
%s
%f
""" % (emp_id, first, last, salary)
print "-" * 80
print "All Employees:"
print "-" * 80
recordset = context.Queries.list_all_employees().dictionaries()
rownum = 1
for record in recordset:
print "Row %d" % (rownum)
rownum = rownum + 1
for key in record.keys():
print key, "=", record[key]
print "-" * 80
return printed
----------------------
"insertEmployeeQuery" is a ZSQL method, using a Gadfly DB Connection, that
looks like this:
----------------------
Arguments: emp_id, first, last, salary
insert into employees (emp_id, first, last, salary) values
(
<dtml-sqlvar emp_id type="int">,
<dtml-sqlvar first type="string">,
<dtml-sqlvar last type="string">,
<dtml-sqlvar salary type="float">
)
----------------------
The error is:
----------------------
Error Type
Missing Input
Error Message
Missing input variable, emp_id
----------------------
Obviously, the problem lies in passing the arguments to the ZSQL method but
I can't seem to find the right syntax. I know I could do this from a DTML
Method instead of a Python Script but I am more interested in seeing how
DTML and Python work together. Can anyone help me out?
Many thanks,
Mark