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> /> <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 )
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 ? 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> /> <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 )
Am Dienstag, 3. April 2001 10:21 schrieb Gitte Wange:
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 ?
Gitte
I don't have time to explain it, but maybe this snippets from my code can help you: First part, display the items in a table: --------------------------- <FORM action="board_delProcessor" mehtod=post> <TABLE border=1 width=75% align=center bgcolor="lightgrey" bordercolorlight="#999999" bordercolordark="#666666" cellspacing="1" cellpadding="8"> <dtml-with entries> <dtml-in "objectValues(['Message Board Entry'])"> <dtml-var manage_html> </dtml-in> </dtml-with> </TABLE> [...] Second part, manage_html ------------------- <TR> <TD align="center" width ="5%"><INPUT type ="checkbox" name="delID" value="<dtml-var id>"></TD> <TD align="left" width ="20%"><dtml-var message_subject></TD> <TD align="left" width ="5%"><dtml-var author></TD> <TD align="left" width ="5%"><FONT size=-2><dtml-var post_date></FONT></TD> </TR> Third part, the board_delProcessor ------------------------- <dtml-with entries> <dtml-call "REQUEST.set('delObj',delID)"> <dtml-call "manage_delObjects(delObj,REQUEST)"> </dtml-with> This works on my message board management also for multiple posts hth, Jan -- Jan@MountainbikeHQ.de http://www.MountainbikeHQ.de - Your home for DH, DS and CC Mountainbiking
Sorry for me being slow on this but the items I need to delete is in my MySQL database. So I only need the code for iterating through the selected items. Then call the sqlMethod that deletes the items whenever a item is checked. So I had thought of something like: <FORM ACTION="DelItems"> <TABLE> <dtml-in ItemQuery> <TR> <TD><dtml-var itemname></TD> <TD><INPUT TYPE="checkbox" NAME="DeleteArray[]" VALUE="<dtml-var id>"></TD> </TR> </TABLE> </FORM> The DelItems method: <dtml-with DeleteArray[]> <dtml-call sqlDelItem> </dtml-with> But how do you make an array in Zope and is it the correct way to iterate through it ? Gitte On 03 Apr 2001 11:07:49 +0200, Jan Lentfer wrote:
Am Dienstag, 3. April 2001 10:21 schrieb Gitte Wange:
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 ?
Gitte
I don't have time to explain it, but maybe this snippets from my code can help you:
First part, display the items in a table: --------------------------- <FORM action="board_delProcessor" mehtod=post>
<TABLE border=1 width=75% align=center bgcolor="lightgrey" bordercolorlight="#999999" bordercolordark="#666666" cellspacing="1" cellpadding="8">
<dtml-with entries>
<dtml-in "objectValues(['Message Board Entry'])"> <dtml-var manage_html> </dtml-in> </dtml-with> </TABLE> [...]
Second part, manage_html ------------------- <TR> <TD align="center" width ="5%"><INPUT type ="checkbox" name="delID" value="<dtml-var id>"></TD> <TD align="left" width ="20%"><dtml-var message_subject></TD> <TD align="left" width ="5%"><dtml-var author></TD> <TD align="left" width ="5%"><FONT size=-2><dtml-var post_date></FONT></TD> </TR>
Third part, the board_delProcessor ------------------------- <dtml-with entries> <dtml-call "REQUEST.set('delObj',delID)"> <dtml-call "manage_delObjects(delObj,REQUEST)"> </dtml-with>
This works on my message board management also for multiple posts
hth,
Jan
-- Jan@MountainbikeHQ.de http://www.MountainbikeHQ.de - Your home for DH, DS and CC Mountainbiking
_______________________________________________ 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 )
Am Dienstag, 3. April 2001 12:00 schrieben Sie:
Sorry for me being slow on this but the items I need to delete is in my MySQL database. So I only need the code for iterating through the selected items. Then call the sqlMethod that deletes the items whenever a item is checked.
Ooops, my fault. I forgot that you work with MySQL. What I wrote is just to delete Zope objects. I don't know about MySQL... Jan -- Jan@MountainbikeHQ.de http://www.MountainbikeHQ.de - Your home for DH, DS and CC Mountainbiking
Hi Gitte, please read carefully! The name of your gadget in the form has to be prepended with the type zope should coerse its content into. So you have to write <input type="checkbox" name="DeleteArray:list" ... Please please forget all the things with PHP, Perl etc ;) Regards Tino Gitte Wange wrote:
Sorry for me being slow on this but the items I need to delete is in my MySQL database. So I only need the code for iterating through the selected items. Then call the sqlMethod that deletes the items whenever a item is checked.
So I had thought of something like: <FORM ACTION="DelItems"> <TABLE> <dtml-in ItemQuery> <TR> <TD><dtml-var itemname></TD> <TD><INPUT TYPE="checkbox" NAME="DeleteArray[]" VALUE="<dtml-var id>"></TD> </TR> </TABLE> </FORM>
The DelItems method: <dtml-with DeleteArray[]> <dtml-call sqlDelItem> </dtml-with>
But how do you make an array in Zope and is it the correct way to iterate through it ?
Gitte
On 03 Apr 2001 11:07:49 +0200, Jan Lentfer wrote:
Am Dienstag, 3. April 2001 10:21 schrieb Gitte Wange:
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 ?
Gitte
I don't have time to explain it, but maybe this snippets from my code can help you:
First part, display the items in a table: --------------------------- <FORM action="board_delProcessor" mehtod=post>
<TABLE border=1 width=75% align=center bgcolor="lightgrey" bordercolorlight="#999999" bordercolordark="#666666" cellspacing="1" cellpadding="8">
<dtml-with entries>
<dtml-in "objectValues(['Message Board Entry'])"> <dtml-var manage_html> </dtml-in> </dtml-with> </TABLE> [...]
Second part, manage_html ------------------- <TR> <TD align="center" width ="5%"><INPUT type ="checkbox" name="delID" value="<dtml-var id>"></TD> <TD align="left" width ="20%"><dtml-var message_subject></TD> <TD align="left" width ="5%"><dtml-var author></TD> <TD align="left" width ="5%"><FONT size=-2><dtml-var post_date></FONT></TD> </TR>
Third part, the board_delProcessor ------------------------- <dtml-with entries> <dtml-call "REQUEST.set('delObj',delID)"> <dtml-call "manage_delObjects(delObj,REQUEST)"> </dtml-with>
This works on my message board management also for multiple posts
hth,
Jan
-- Jan@MountainbikeHQ.de http://www.MountainbikeHQ.de - Your home for DH, DS and CC Mountainbiking
_______________________________________________ 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 )
Okay now it passes something - that's better that before :-) But what argument must I thn write in my sql method? It looks like it passes "DeleteClips:list=<id>" so should I put DeleteClips:list in as an argument in my sql method ? Gitte On 03 Apr 2001 12:59:40 +0200, Tino Wildenhain wrote:
Hi Gitte,
please read carefully!
The name of your gadget in the form has to be prepended with the type zope should coerse its content into. So you have to write <input type="checkbox" name="DeleteArray:list" ...
Please please forget all the things with PHP, Perl etc ;)
Regards Tino
Gitte Wange wrote:
Sorry for me being slow on this but the items I need to delete is in my MySQL database. So I only need the code for iterating through the selected items. Then call the sqlMethod that deletes the items whenever a item is checked.
So I had thought of something like: <FORM ACTION="DelItems"> <TABLE> <dtml-in ItemQuery> <TR> <TD><dtml-var itemname></TD> <TD><INPUT TYPE="checkbox" NAME="DeleteArray[]" VALUE="<dtml-var id>"></TD> </TR> </TABLE> </FORM>
The DelItems method: <dtml-with DeleteArray[]> <dtml-call sqlDelItem> </dtml-with>
But how do you make an array in Zope and is it the correct way to iterate through it ?
Gitte
On 03 Apr 2001 11:07:49 +0200, Jan Lentfer wrote:
Am Dienstag, 3. April 2001 10:21 schrieb Gitte Wange:
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 ?
Gitte
I don't have time to explain it, but maybe this snippets from my code can help you:
First part, display the items in a table: --------------------------- <FORM action="board_delProcessor" mehtod=post>
<TABLE border=1 width=75% align=center bgcolor="lightgrey" bordercolorlight="#999999" bordercolordark="#666666" cellspacing="1" cellpadding="8">
<dtml-with entries>
<dtml-in "objectValues(['Message Board Entry'])"> <dtml-var manage_html> </dtml-in> </dtml-with> </TABLE> [...]
Second part, manage_html ------------------- <TR> <TD align="center" width ="5%"><INPUT type ="checkbox" name="delID" value="<dtml-var id>"></TD> <TD align="left" width ="20%"><dtml-var message_subject></TD> <TD align="left" width ="5%"><dtml-var author></TD> <TD align="left" width ="5%"><FONT size=-2><dtml-var post_date></FONT></TD> </TR>
Third part, the board_delProcessor ------------------------- <dtml-with entries> <dtml-call "REQUEST.set('delObj',delID)"> <dtml-call "manage_delObjects(delObj,REQUEST)"> </dtml-with>
This works on my message board management also for multiple posts
hth,
Jan
-- Jan@MountainbikeHQ.de http://www.MountainbikeHQ.de - Your home for DH, DS and CC Mountainbiking
_______________________________________________ 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 )
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> 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> /> <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 )
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> /> <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 )
Hi Gitte, time is on your side if you are with zope :) We brougt up a complete b2b e-commerce site with 3 not-even-python-knowers and one well-python-knower (me) We did not know anything about zope and it was with first betas of zope 2.0 :) 4 Months later the site was up :) Ok, you should get a little bit familar with the way the web works, what is sent by the browser and what in return from the server. A little page with <dtml-var REQUEST> is also very helpful for understanding. Please see the many examples how to work with ZSQL methods, how to explicitely pass parameters to them. The loop you got already so its all you need. Hint: Your zsql-method could look like: DELETE FROM TABLE blah WHERE ItemID=<dtml-sqlvar arg_ItemToDelete type=string> So you would call it inside your DTML-Method: <dtml-call expr="YourZSQLMethodToDeleteItems(arg_ItemToDelete=_['sequence-item'])"> (Note: the _['sequence-item'] expression is used to get from the namespace (_) the value for the name 'sequence-item'. Sequence-item runs from the beginning to end of your sequence (list, array) in the in-tag. NB: sequence-item is unhandy because its hypenation and its special meaning in python: hypenation is the minus-sign. You can expect a better solution to this soon) Alternatively: DELETE FROM TABLE blah WHERE ItmID in ('<dtml-var "_.string.join(arg_ItemSequence,_.chr(39)+','+_.chr(39))" sql_quote>') With the call: <dtml-call expr="YourZSQLMethodToDeleteAllAtOnce(arg_ItemSequence=ids)"> (in this case no in-tag is required) However, to understand the above examples please consult the various documents all around on python at first and zope in special. Remember: if you are really in trouble with the shedule and need to get things done, consider using professional help. There are now many companys and single persons here who would help you. (not me, I dont have the time ;) Regards Tino Gitte Wange wrote:
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> /> <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 )
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 `------------------>
Hi Casey, Casey Duncan wrote:
Gitte Wange wrote:
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)
Thats even better than my solution! :-) Used the special methods very rarely so far ;) Regards Tino
On 03 Apr 2001 08:49:14 -0600, Casey Duncan wrote:
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 `------------------>
Well that helped a little. I set the Form ACTION-tag to sqlDeleteClips (which is my sql method) and the checkbox name to "ids:list" When I hit the submit button, you see a Zope page where there is a input box to enter the ids in .. but I just want it do delete the ones that are selected ??? -- ************************ Gitte Wange Jensen System Squid Developer MMManager Aps +45 29 72 79 72 gitte@mmmanager.org ************************
Gitte Wange wrote:
Well that helped a little. I set the Form ACTION-tag to sqlDeleteClips (which is my sql method) and the checkbox name to "ids:list" When I hit the submit button, you see a Zope page where there is a input box to enter the ids in .. but I just want it do delete the ones that are selected ???
You can't point the action of the form directly to the SQL method because it is not a web template. I would suggest having the form call itself and add some dtml logic at the top to determine that the user deleted something. Have it then fire off the SQL method before drawing the checkboxes. Something like so: <dtml-if delete> <dtml-call name="sqlDeleteClips"> </dtml-if> <form action="&dtml-URL;"> <dtml-in sqlSelectClips> <input type="checkbox" name="ids:list" value="&dtml-id;" /> <dtml-var name="title"><br /> </dtml-in> <input type="submit" name="delete" value="Delete" /> </form> Substitute your field names for "id" and "title" above. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
participants (6)
-
Casey Duncan -
Farrell, Troy -
Gitte Wange -
Gitte Wange -
Jan Lentfer -
Tino Wildenhain