[Zope] Delete multiple posts

Gitte Wange gitte@babytux.dk
03 Apr 2001 16:14:40 +0200


On 03 Apr 2001 11:55:57 +0200, Tino Wildenhain wrote:
> 
> Hi Gitte,
> 
> Gitte Wange wrote:
> > 
> > Well I'm sorry to say this, but it seems a bit more complicated than
> > what I need. Isn't it possible to make an array out of a select box
> > (with only the selected items in the array) and just run through this
> > array to delete the items ?
> 
> Thats no way complicated. The "list" is the word python people use
> instead of "array" :-) If you note for your checkbox name
> a name and :list, zope automatically converts all selected entrys into
> a list containing the selected entrys. If you dont write :list, it does
> it anyway if there is more then one selected. To be save, use "ids:list"
> so the list is called ids. (refering to the example below)
> 
> As mentioned, you dont have to delete item by item if they are stored 
> in Zope as objects. you only need to pass it to the manage_delObjects
> method of the folder:
> 
> <dtml-call expr="yourfolder_with_items.manage_delObjects(ids)">
> 
> (schould work. Untested)
> 
> If you have your items in a sql database, you may want to ilterate like
> this:
> 
> <dtml-in ids>
>   <dtml-call
> expr="dosomethingtodelete(itemtodelete=_['sequence-item'])">
> </dtml-in>

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
> 
> Regards
> Tino
> > 
> > Gitte
> > 
> > On 02 Apr 2001 09:47:41 -0500, Farrell, Troy wrote:
> > > I use a python script to do this all day :)
> > > Zope Coolness: You don't have to run through the array.  Pass the array as a
> > > parameter to manage_delObjects.
> > > Remember to bind the namespace to _
> > > The check boxes are listed as follows in a form that calls my script:
> > >
> > > <dtml-in expr="objectValues()">
> > > <li><input type="checkbox" name="ids:list" value="<dtml-var
> > > name="id">"<dtml-if name="checkall"> checked="checked"</dtml-if> />&nbsp<a
> > > href="&dtml-absolute_url;?ex=.log"><dtml-var name="title"></a></li>
> > > </dtml-in>
> > >
> > > The Script:
> > >
> > > ## Script (Python) "manageLogFiles"
> > > ##bind container=container
> > > ##bind context=context
> > > ##bind namespace=_
> > > ##bind script=script
> > > ##bind subpath=traverse_subpath
> > > ##parameters=
> > > ##title=
> > > ##
> > > if context.REQUEST.has_key('ids') and context.REQUEST.has_key('doThis'):
> > >   if context.REQUEST.doThis == 'Delete these!':
> > >     # Delete all selected LogFiles
> > >     # note the .logs. in the command below
> > >     context.logs.manage_delObjects(context.REQUEST.ids)
> > >     context.REQUEST.RESPONSE.redirect(context.REQUEST.SourceURL)
> > >
> > >   else :
> > >     # I don't know what to do
> > >     raise KeyError
> > >
> > > else:
> > >   # Do this if they didn't check any of the boxes
> > >   # I used to raise a KeyError, but that is stupid
> > >   # Nobody wants a computer to tell them that they pushed
> > >   # a button at the wrong time.  Now, we essentially do
> > >   # nothing, but send them back to where they came from.
> > >   # raise KeyError
> > >   context.REQUEST.RESPONSE.redirect(context.REQUEST.SourceURL)
> > >
> > > Troy
> > >
> > > -----Original Message-----
> > > From: Gitte Wange [mailto:gitte@babytux.dk]
> > > Sent: Monday, April 02, 2001 6:05 AM
> > > To: zope@zope.org
> > > Subject: [Zope] Delete multiple posts
> > >
> > >
> > > Hello,
> > >
> > > I have a list of items where it should be possible to delete all the
> > > items you wish.
> > > Each item have a checkbox with the value equal to them itemid.
> > >
> > > I have done this is PHP just by naming these checkboxes "deletearr[]" to
> > > make an array, then run through the array an delete each item.
> > > But how do I do the same thing in Zope ?
> > >
> > > Or - a more specifik question - can I make an array the same way in Zope
> > > that I did in PHP ?
> > >
> > > Regards,
> > > --
> > > ************************
> > > Gitte Wange Jensen
> > >
> > > System Squid Developer
> > > MMManager Aps
> > > +45 29 72 79 72
> > >
> > > gitte@mmmanager.org
> > > ************************
> > >
> > >
> > > _______________________________________________
> > > 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 )
> > >
> > > _______________________________________________
> > > 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 )
> > 
> > _______________________________________________
> > 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 )