[Product-Developers] Aborting deletion of objects

Johannes Schwenk johannes.schwenk at gmail.com
Thu May 14 17:24:38 UTC 2009


Hello all!

I'm currently developing a Archetypes based product for Plone 3.1.7 (Zope 
2.10.6-final, python 2.4.4, linux2). 

What is the best and safest way to abort object deletion and display an 
informative message? I want to abort deletion of objects of a custom content 
type iff it has references to other objects. The user should be redirected to 
the base view of the object, if he tries to delete (actions menu or otherwise 
ttw) a object with references still in place. The references are implemented 
using the ReferenceField from Archetypes.

Currently I am trying to get things working by implementing an adapter for the 
IObjectWillBeRemovedEvent event:

@adapter(IEntry, IObjectWillBeRemovedEvent)
def verifyOnDeletion(obj, event):
	"""
	"""
[...]
	raise zExceptions.Redirect(obj.asolute_url())
[...]

The function never gets called... Yes I registered the adapter with 
<subscriber handler=".vocabulary.verifyOnDeletion" />. Other adapters defined 
that way get called...

Am I on the right path? Input really appreciated!

Thanks,
Johannes




More information about the Product-Developers mailing list