[Zope] How to Delete ZClass Instances programmatically??

Dieter Maurer dieter@handshake.de
Tue, 29 Aug 2000 23:19:58 +0200 (CEST)


Jean Jordaan writes:
 > I've found the "How-To: Adding ZClass Instances Programmatically",
 > but now I'm looking for the *Deleting ZClass Instances* one!
 > 
 > I'm trying this as a beginning (hacked from the Zope management
 > interface)::
 > ....
 >     <dtml-if "AUTHENTICATED_USER.has_role('ContentManager')">
 >       <input type="submit" name="manage_delObjects:method" value="Delete">
 >       </form>
 >     </dtml-if>
 > 
 > Problems: 
 > 
 >  - it sends me to the management screen afterwards, and I'm 
 >    calling it from the public interface. 
This means, you want to look at the source of "manage_delObjects"
(-> "OFS.ObjectManager") to see, how it sends you to the management interface.

You will see, that it contains:

	if REQUEST is not None:
	  return self.manage_main(self,REQUEST,update_menu)

Thus, do not pass it a REQUEST.

This implies, that you do not call it directly from the form,
but call a dtml method from the form, that then calls
"manage_delObjects" with the "ids" and no REQUEST.

It may be necessary to set a proxy role for this method.

 >  - I don't necessarily want to give the 'ContentManager' rights
 >    to delete objects; I'd rather manage this through a delete 
 >    method with the appropriate proxy role.
Then, this should get your method mentioned above.



Dieter