ftw.trash is a Plone addon modifying the behavior when deleting content.
When a user deletes content, it will actually not be deleted but marked as trashed.
Trashed content can then be restored when needed.
Table of Contents
Be aware that
ftw.trashrequires and installs
ftw.trashto the eggs in your buildout configuration:
[instance] eggs += ... ftw.trash
ftw.trashaddon in Plone (Addons control panel or portal_setup or quickinstaller).
Deleting content looks exactly as in standard Plone, but it does not actually delete the content but only hide it.
Administrators can restore content with a global trash view, accessible via the user menu.
Personal trashes are not implemented at the moment.
The catalog is patched, so that it includes the default query
This makes sure that we only work with not trashed objects by default.
If you want to access trashed objects, you can simply use the query keyword
with one of these values:
False: only return objects which are not trashed.
True: only return objects which are trashed.
None: do not apply "trashed" filter, return trashed and not trashed objects.
These filters only apply when
portal_catalog.searchResults is used.
portal_catalog.unrestrictedSearchResults the behavior is different,
trashed=None, since this method is not patched.
manage_delObjects so that it trashes the content instead of deleting
ftw.trash also adds new methods:
parent.manage_trashObjects([id1, id2, ..]): trashes the contents.
parent.manage_immediatelyDeleteObjects(([id1, id2, ..]): immediately deletes the contents without trashing it.
parent.manage_delObjects([id1, id2, ..]): trashes the contents. If called from ZMI (or within link integrity checker), the content is immediately deleted.
The patches are applied on the site root, on DX- and on AT-folders when
is installed in the path.
For the methods to work properly, the Generic Setup profile must be installed as well.
By default, restoring a page can be compared to adding a new page to its container.
Therefore we require the
Add portal content permission on the parent.
This may depend on the application and the content type though: there are content types
which can be seen as part of the content of their parents, in which case we'd like to
Modify portal content permission for restoring instead.
Therefore this behavior can be manipulated by simply registering an adapter for the restored
content for which we want to change the behavior.
These object events are fired:
- ftw.trash.interfaces.IBeforeObjectTrashedEvent: the object will be trashed.
- ftw.trash.interfaces.IObjectTrashedEvent: the object has been trashed.
- ftw.trash.interfaces.IBeforeObjectRestoredEvent: the object will be restored.
- ftw.trash.interfaces.IObjectRestoredEvent: the object has been restored.
- When content is deleted, it is marked as
IRestorable, children are only marked as
- Only the root node of the deleted structure can be restored and thus provides
IRestorable. Restoring children without their deleted parents cannot work since the parent is missing.
- Trashed content is not moved.
- The catalog's
searchResultsmethod is patched so that it filters trashed objects by default.
- Trashed content is prevented from beeing published / accessible through the browser unless
the user has the
- For restoring content, the permissions
Restore trashed contentand
Add portal contentare required. The
Restore trashed contentis granted by default to the roles
Site Administratoron the site root.
- Fork this repo
- Clone your fork
ln -s development.cfg buildout.cfg
bin/test to test your changes.
Or start an instance by running
- Github: https://github.com/4teamwork/ftw.trash
- Issues: https://github.com/4teamwork/ftw.trash/issues
- Pypi: http://pypi.python.org/pypi/ftw.trash
This package is copyright by 4teamwork.
ftw.trash is licensed under GNU General Public License, version 2.