Re: [Zope] NEWBIE: manage_delObject, manage_delProperties?
I am using manage_delObjects method directly over the object. This is not very well documented, It's the only way I found to do it.
>>>>>>>>>>>> Mensaje original <<<<<<<<<<<<<<<<<<
El 29/10/01, 20:11:13, michael@exasource.com (Michael) escribió sobre el tema [Zope] NEWBIE: manage_delObject, manage_delProperties?:
I'm trying to figure out how to delete an object from Zope. I use manage_editProperties to add and index, and manage_changeProperties to edit and reindex, that all works fine, but I'm not sure how to delete.
I am using :
<dtml-call "propertysheets.entry_info.manage_delProperties(REQUEST)"> and this just gives me an error message and I also tried:
<dtml-call "propertysheets.entry_info.manage_delObject(REQUEST)"> but that errors out too.
I am using this on a database object that contains the fields: id (this is set by ZopeTime) first_name last_name email_address mail_request interest_area
Can anybody point out what I am doing wrong?
Michael
_______________________________________________ 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 )
manage_delObjects and manage_delProperties expect a list. (List of ids) Tommy Innovation: The Best Way To Predict The Future ... Is To Create It.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Julián Muñoz Domínguez Sent: Monday, October 29, 2001 1:56 PM To: zope@zope.org Subject: Re: [Zope] NEWBIE: manage_delObject, manage_delProperties?
I am using manage_delObjects method directly over the object. This is not very well documented, It's the only way I found to do it.
>>>>>>>>>>>>> Mensaje original <<<<<<<<<<<<<<<<<<
El 29/10/01, 20:11:13, michael@exasource.com (Michael) escribió sobre el tema [Zope] NEWBIE: manage_delObject, manage_delProperties?:
I'm trying to figure out how to delete an object from Zope. I use manage_editProperties to add and index, and manage_changeProperties to edit and reindex, that all works fine, but I'm not sure how to delete.
I am using :
<dtml-call "propertysheets.entry_info.manage_delProperties(REQUEST)"> and this just gives me an error message and I also tried:
<dtml-call "propertysheets.entry_info.manage_delObject(REQUEST)"> but that errors out too.
I am using this on a database object that contains the fields: id (this is set by ZopeTime) first_name last_name email_address mail_request interest_area
Can anybody point out what I am doing wrong?
Michael
_______________________________________________ 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 Tuesday 29 October 2001 20:1, Michael wrote:
I'm trying to figure out how to delete an object from Zope. I use manage_editProperties to add and index, and manage_changeProperties to edit and reindex, that all works fine, but I'm not sure how to delete.
I am using :
<dtml-call "propertysheets.entry_info.manage_delProperties(REQUEST)"> and this just gives me an error message and I also tried:
<dtml-call "propertysheets.entry_info.manage_delObject(REQUEST)"> but that errors out too.
You have to call delObject(s) on the parent, because this is the object manager you are telling "delete one(some) of your objects". If you are calling it on a folder (object manager), and you want to delete the object "entry_info" that lies in this folder, use this: <dtml-call "manage_delObjects['entry_info']"> If you are calling your method on the object to be deleted itself (usually not so elegant), your DTML should look something like this: <dtml-call "aq_parent.manage_delObjects([id])"> Keep in mind that manage_delObjects expects a list as a parameter. This list holds the ids of the (contained) objects to be deleted, not the objects themselves. hth, Danny
On Mon, 29 Oct 2001, Danny William Adair wrote:
You have to call delObject(s) on the parent, because this is the object manager you are telling "delete one(some) of your objects".
If you are calling it on a folder (object manager), and you want to delete the object "entry_info" that lies in this folder, use this:
<dtml-call "manage_delObjects['entry_info']">
If you are calling your method on the object to be deleted itself (usually not so elegant), your DTML should look something like this:
<dtml-call "aq_parent.manage_delObjects([id])">
Keep in mind that manage_delObjects expects a list as a parameter. This list holds the ids of the (contained) objects to be deleted, not the objects themselves.
hth, Danny
I used second method above, <dtml-call "aq_parent.manage_delObjects([id])"> and it works, but I get a Site error: Cannot locate object at: machine.domain:8080/file/path/to/object/1004153812, even though the objects are being deleted ?
Hi Michael! I think it is not wise to call delObjects() within the object to be deleted. As soon as the object is deleted, it obviously cannot be accessed anymore. But maybe that's exactly what Zope is trying to do afterwards... Use the first version and there will be no problems. If you used a link to your "delete" method: <dtml-in my_entries> ... <a href="delete">delete</a> ... </dtml-in> then change them so that the parent is called: <dtml-let parent_url="my_entries.absolute_url()"> <dtml-in my_entries> ... <a href="<dtml-var parent_url>/delete?id=<dtml-var id>">delete</a> ... </dtml-in> </dtml-let> Now, the id of the object to be deleted can be accessed through "REQUEST['id']" when you call "delete" through the link, so the "delete" method of your folder would look like: <dtml-call "manage_delObjects([REQUEST['id']])"> Btw, if you have a look at what the management interface does, you'll see how easy it is to provide checkboxes and thus be able to delete a couple of objects at the same time. In your loop that lists the contained entries, you would have <input type="checkbox" name="ids:list" value="<dtml-var id>"> in front of each listed object. Then you would have a submit button that calls "delete" on the folder <form action="&dtml-absolute_url;" method="post"> ... <dtml-let parent_url="my_entries.absolute_url()"> <dtml-in my_entries> ... <input type="checkbox" name="ids:list" value="<dtml-var id>"><dtml-var id><br /> ... </dtml-in> </dtml-let> ... <input type="submit" name="delete:method" value="delete entries" /> </form> now you can do: <dtml-call "manage_delObjects(REQUEST['ids'])"> inside the folder's "delete" method to delete all the objects that have been selected. REQUEST['ids'] already is a list! Just a suggestion... hth, Danny On Wednesday 31 October 2001 12:10, Michael wrote:
On Mon, 29 Oct 2001, Danny William Adair wrote:
You have to call delObject(s) on the parent, because this is the object manager you are telling "delete one(some) of your objects".
If you are calling it on a folder (object manager), and you want to delete the object "entry_info" that lies in this folder, use this:
<dtml-call "manage_delObjects['entry_info']">
If you are calling your method on the object to be deleted itself (usually not so elegant), your DTML should look something like this:
<dtml-call "aq_parent.manage_delObjects([id])">
Keep in mind that manage_delObjects expects a list as a parameter. This list holds the ids of the (contained) objects to be deleted, not the objects themselves.
hth, Danny
I used second method above, <dtml-call "aq_parent.manage_delObjects([id])"> and it works, but I get a Site error: Cannot locate object at: machine.domain:8080/file/path/to/object/1004153812, even though the objects are being deleted ?
Hi Danny, I worked on this until 12:30 last night and finally got it to work! Thanks so much for the explanation, I looked everywhere and couldn't find much documentation on this. I was calling my "delete" a little differently than what you described, which is why it took a while to get it working, but I couldn't have done it without your help. You did a great job of explaining the concept. Thanks again. Michael On Tue, 30 Oct 2001, Danny William Adair wrote:
Hi Michael!
I think it is not wise to call delObjects() within the object to be deleted. As soon as the object is deleted, it obviously cannot be accessed anymore. But maybe that's exactly what Zope is trying to do afterwards...
Use the first version and there will be no problems. If you used a link to your "delete" method:
<dtml-in my_entries> .... <a href="delete">delete</a> .... </dtml-in>
then change them so that the parent is called: <dtml-let parent_url="my_entries.absolute_url()"> <dtml-in my_entries> .... <a href="<dtml-var parent_url>/delete?id=<dtml-var id>">delete</a> .... </dtml-in> </dtml-let>
Now, the id of the object to be deleted can be accessed through "REQUEST['id']" when you call "delete" through the link, so the "delete" method of your folder would look like:
<dtml-call "manage_delObjects([REQUEST['id']])">
Btw, if you have a look at what the management interface does, you'll see how easy it is to provide checkboxes and thus be able to delete a couple of objects at the same time.
In your loop that lists the contained entries, you would have <input type="checkbox" name="ids:list" value="<dtml-var id>"> in front of each listed object.
Then you would have a submit button that calls "delete" on the folder
<form action="&dtml-absolute_url;" method="post"> .... <dtml-let parent_url="my_entries.absolute_url()"> <dtml-in my_entries> .... <input type="checkbox" name="ids:list" value="<dtml-var id>"><dtml-var id><br /> .... </dtml-in> </dtml-let> .... <input type="submit" name="delete:method" value="delete entries" /> </form>
now you can do: <dtml-call "manage_delObjects(REQUEST['ids'])">
inside the folder's "delete" method to delete all the objects that have been selected. REQUEST['ids'] already is a list!
Just a suggestion...
hth, Danny
participants (4)
-
Danny William Adair -
Julián Muñoz Domínguez -
Michael -
Tommy Johnson