[Zope] delete zclass instance

Jeffrey Shell Jeffrey@digicool.com
Fri, 17 Sep 1999 18:47:46 -0400


> Thanks for the reply.
> 
> Ok.  So I copied my ItemClass_add(constructor) to ItemClass_delete and
> then changed the following line:
> 
> <!--#with "ItemClass.createInObjectManager(REQUEST['id'], REQUEST)"-->
> 
> to:
> 
> <!--#with "ItemClass.manage_delObjects(self, REQUEST['id'], 
> REQUEST)"-->
> 
> but I'm getting a NameError with 'self'.

When you're calling "createInObjectManager", you're calling a Method on
the class itself.  manage_delObjects is a method on ObjectManager
instances to delete items that they contain.  So in this caise, you want
to delete the instance.  You can do:

<!--#with folderId-->
 <!--#call "manage_delObjects([REQUEST['id'])"-->
<!--#/with-->

(where folderId is the id of the folder/object manager containing the
object you want to delete.  You could also do:
<!--#call expr="folderId.manage_delObjects([REQUEST['id'])"--> without
the with tags.)

manage_delObjects is what is called when you mark checkboxes in the
Contents list of a folder and click delete.  What's passed in _must_ be
a list of ID's (even if it's a single ID, it must be surrounded by []).

You don't need to pass REQUEST as the last parameter in this case.  Many
Zope methods that are primarily accessed through the management
interface use REQUEST as a means of knowing they were accessed as a
direct action (submitting a form) and should return an HTML page).  When
Scripting (using expr="..."), you usually don't need to pass it in.
This holds for almost every method beginning with manage_.