[Zope] NEWBIE: manage_delObject, Thanks!!

Michael michael@exasource.com
Wed, 31 Oct 2001 10:40:06 -0700


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