delete multiple records sql python etc
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
Hi Todd, at the risk of being gratuitous, wouldn't it be easier to make a primary key on user_accounts something like user_accounts_id ? cheers, Garry On 5 Dec 2001, at 22:49, Todd Graham wrote: From: "Todd Graham" <tgraham@speakeasy.net> To: <zope@zope.org> Subject: [Zope] delete multiple records sql python etc Date sent: Wed, 5 Dec 2001 22:49:57 -0800
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 )
+-------------------------------------------+ Garry Steedman mailto:gs@styrax.com Styrax Associates http://www.styrax.com/ "The Good Man has no shape." +-------------------------------------------+
[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
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 )
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
participants (4)
-
Garry Steedman -
Jim Penny -
Thomas B. Passin -
Todd Graham