[Zope] Delete multiple posts

Casey Duncan cduncan@kaivo.com
Tue, 03 Apr 2001 08:49:14 -0600


Gitte Wange wrote:
> 
> 
> well I made the list: NAME="ids:list" in the checkbox line
> When you hit the deletebutton a method is called.
> The code for deletion is here:
> <dtml-in ids>
>         <dtml-call sqlDeleteClips> <-- That's the sqlmethod
> </dtml-in>
> 
> What's funny is that I get an 400 error.
> And I have 3 hidden fiels in the same form - normally they would be
> passed as ActionList=1 etc. etc. but now they are passed as
> ActionList=['1', '1', '1', '1', '1', '1', '1', '1']
> 
> Yes I know I should learn some python but I'm working against time :-)
> 
> Gitte

Thought I would jump in:

You do not need to explicitly iterate the list in dtml. You can simply
pass the list whole to the ZSQL method and delete all the items in one
SQL call. This will be much more efficient both in code and overhead.
The ZSQL method would be something like:

Arguments:
    ids:list

Code:
    DELETE FROM mytable WHERE <dtml-sqltest name="ids" column="id"
type="int" multiple>

If you pass is a list like [2,4,6,8] the resulting SQL will look like:

DELETE FROM mytable WHERE id in (2,4,6,8)

hth,
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>