[Zope] NEWBIE: manage_delObject, manage_delProperties?

Danny William Adair danny@adair.net
Wed, 31 Oct 2001 11:51:52 +1300


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 ?