[Zope] delete multiple records sql python etc

H.de.Wit@SFK.NL H.de.Wit@SFK.NL
Thu, 6 Dec 2001 09:54:19 +0100


I hope i understand your question correctly:

How do i delete records from a database, based on a form where i use
checkboxes to indicate which records have to be deleted.

I did this with a list converter (table html is left out)

<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.


Met vriendelijke groeten,

Hans de Wit
Stichting Farmaceutische Kengetallen
Postbus 30460
2500 GL  DEN HAAG
Tel. 070-3737448
Fax 070-3737445


                                                                                                                    
                    "Todd Graham"                                                                                   
                    <tgraham@spea        To:     <zope@zope.org>                                                    
                    keasy.net>           cc:                                                                        
                    Sent by:             Subject:     [Zope] delete multiple records sql python etc                 
                    zope-admin@zo                                                                                   
                    pe.org                                                                                          
                                                                                                                    
                                                                                                                    
                    06-12-01                                                                                        
                    07:49 AM                                                                                        
                                                                                                                    
                                                                                                                    




I've looked through the archives and seen similar posts but none of the
replies seem to solve my problem.  Here goes...

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.


Thanks in advance,

Todd



_______________________________________________
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 )