passing the parameters to zsql method
Hello! I'm trying to pass the form parameters from page template to zsql method. A piece of code follows: <form action="clients_add_sql"> <input type="text" name="name"> <input type="text" name="account"> <input type="submit"> </form> clients_add_sql: insert into table(name,account) values (<dtml-sqlvar name type=string>, <dtml-sqlvar account type=string>); the problem is when i click the 'submit' button, the form "clients_add_sql Input Data Enter query parameters:" appears. Does someone know how i can pass the form parameters to zsql method directly? --
Denis V. Gudtsov wrote:
<form action="clients_add_sql"> <input type="text" name="name"> <input type="text" name="account"> <input type="submit"> </form>
clients_add_sql: insert into table(name,account) values (<dtml-sqlvar name type=string>, <dtml-sqlvar account type=string>);
the problem is when i click the 'submit' button, the form "clients_add_sql Input Data Enter query parameters:" appears.
Does someone know how i can pass the form parameters to zsql method directly?
use an intermediary Script (Python), ie: --- # extract data from form and put into zsql-method. request = continer.REQUEST name = request.form.get('name', None) account = request.form.get('account', None) # Sanity check - do we have values? if name and account: # assume that the zsql-method is in the same folder as this script container.clients_add_sql(name=name, account=account) # if the zsql is not in the same folder as this script, use aquisition #context.clients_add_sql(name=name, account=account) --- As you can see, introducing a script in between has other benefits as well, such as allowing for data verification etc. to call the script change: <form action="clients_add_sql"> to <form action="the_name_of_your_script_goes_here"> hope this helps. /dario -- -- ------------------------------------------------------------------- Dario Lopez-Kästen, IT Systems & Services Chalmers University of Tech. Lyrics applied to programming & application design: "emancipate yourself from mental slavery" - redemption song, b. marley
participants (2)
-
Dario Lopez-Kästen -
Denis V. Gudtsov