[Zope] delete multiple records sql python etc

Todd Graham tgraham@speakeasy.net
Thu, 6 Dec 2001 08:02:10 -0800


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>

throw_away_script is a python script that looks like this:

request = container.REQUEST
throw_away_list=request.throw_away_list
for i in throw_away_list:
      context.SQL_throw_away_onerecord(user_id=i)

The SQL_throw_away_onerecord query is probably not the problem, just
deletes 1 record.


Thanks again everyone.

Todd

----- Original Message -----
From: Thomas B. Passin <tpassin@mitretek.org>
To: <zope@zope.org>
Sent: Thursday, December 06, 2001 7:06 AM
Subject: Re: [Zope] delete multiple records sql python etc


> [Todd Graham]
>
> >
> > I've got a  table called user_accounts that has user_id, application,
> > username that make up the primary key, this is a child table to the
> > user_info table which has user_id as the primary key.
> >
> > As part of the application I want my users to be able to delete multiple
> > rows from the user_accounts table  that are displayed in a form via a
zsql
> > method that looks like :
> >
> > select * from user_accounts
> > where user_id = <dtml-sqlvar user_id>
> >
> > Based on the result sets of the sql method I build a form that lists the

> > username, user_id, application etc, with one checkbox for each record.
> >
> > My question is how do I pass the all the values from one or more rows to
a
> > python script based on whether or not the box is checked.  I've tried
> > several combinations of using record(s) converters and list converters
but
> > at this point I'm stumped.
> >
>
> The question of the day is this: Are you stumped because you don't know
how
> to write SQL to do this, because you don't know how to write an html form
to
> collect the delete requests, because you don't know how to handle  the
form
> data because some checkboxes never get checked, or something else?
>
> Cheers,
>
> Tom P
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>