Sometimes we have some folders or some documents which should have not been deleted. But our customers/users have deleted them and it occurs some errors on application. So we decided to create a new package to prevent delete or/and move actions.

Sometimes we have some folders or some documents which should have not been deleted.

But our customers/users have deleted them and it occurs some errors on application.

So we decided to create a new package to prevent delete or/and move actions.

How it works

We add marker interface to objects which can not be deleted or renamed (= moved).

We subscribe all IItem objects to OFS.interfaces.IObjectWillBeRemovedEvent and OFS.interfaces.IObjectWillBeMovedEvent

When one of these events is received, and object is marked as not deleted or not renamed, we raised an exception and object is not deleted or moved.

In the futur, we expect to add a dashboard to have a view of all contents with these markers interfaces to easily use it.

You can also set some contents not deleteable (for example) as this in your setuphandler :

from collective.preventactions.interfaces import IPreventDelete
from plone import api
from zope.interface import alsoProvides


def post_install(context):
    obj = api.content.get('/Plone/content-not-deleteable')
    alsoProvides(obj, IPreventDelete)

Now you can have a look at source code of package and try it.