[Zope] delete multiple records sql python etc

Jim Penny jpenny@universal-fasteners.com
Thu, 6 Dec 2001 11:32:55 -0500


On Thu, Dec 06, 2001 at 08:02:10AM -0800, Todd Graham wrote:
> I'm stumped because I need to pass three values to the delete method (which
> has three arguments) based on one checkbox in the html form: Ideally I'd
> like to pass the values to a python script where I can check the value of
> the APPLICATION attribute and call different methods based on that value.
> The three values are what make the record unique.
> 
> 
> delete from st_user_accounts
> where EMPLOYEE_ID = <dtml-sqlvar USER_ID type="string">
>      and USERNAME = <dtml-sqlvar USERNAME type="string">
>   and APPLICATION = <dtml-sqlvar APPLICATION type="string">
> 
> 
> Hans had this recommendation which is quite nice but it still only passes
> one argument to the delete method, I need to pass three.
> 
> <form action=throw_away_script  method=post>
> <dtml-in expr="SQL_from_useraccount(user_id=REQUEST['user_id'])">
> <input type="checkbox" name="throw_away_list:list" value="<dtml-var
> user_id>">
> </dtml-in>
> </form>

How about:

 <form action=throw_away_script  method=post>
 <dtml-in expr="SQL_from_useraccount(user_id=REQUEST['user_id'])">
 <input type="checkbox" name="throw_away_list:list" value="('<dtml-var
 user_id>', '<dtml-var username>', '<dtml-var application>')">
 </dtml-in>
 </form>

You might have to do some casts in the scriptpython (snake thingy).   
You have to guarantee that none of the input fields contains an apostrophe.

Jim Penny