Skip to main content

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.

Installation and usage

  • Be aware that ftw.trash requires and installs collective.deletepermission.

  • Add ftw.trash to the eggs in your buildout configuration:

    [instance]
    eggs +=
        ...
        ftw.trash
  • Install the ftw.trash addon 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.

https://github.com/4teamwork/ftw.trash/raw/master/docs/trash.png

Querying

The catalog is patched, so that it includes the default query {'trashed': False}. 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 trashed 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. When using portal_catalog.unrestrictedSearchResults the behavior is different, especially for trashed=None, since this method is not patched.

Manipulate condition for restoring

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 require the 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.

Example:

Events

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.

Internals

  • When content is deleted, it is marked as ITrashed and IRestorable, children are only marked as ITrashed.

  • 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 searchResults method 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 Manager role.

  • For restoring content, the permissions Restore trashed content and Add portal content are required. The Restore trashed content is granted by default to the roles Manager and Site Administrator on the site root.

Development

  1. Fork this repo

  2. Clone your fork

  3. Shell: ln -s development.cfg buildout.cfg

  4. Shell: python bootstrap.py

  5. Shell: bin/buildout

Run bin/test to test your changes.

Or start an instance by running bin/instance fg.

Changelog

1.1.1 (2018-08-03)

  • Show changelog on pypi. [jone]

1.1.0 (2018-08-03)

  • Do not restore earlier trashed children when restoring parent. [jone]

  • Allow deleting content from ZMI. [jone]

  • Fire events when trashing and restoring object. [jone]

  • Do not intercept link integrity checker. [jone]

  • Add “clean trash” functionality to trash view. [jone]

1.0.0 (2018-07-05)

  • Initial implementation [jone]

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ftw.trash-1.1.1.tar.gz (275.0 kB view details)

Uploaded Source

File details

Details for the file ftw.trash-1.1.1.tar.gz.

File metadata

  • Download URL: ftw.trash-1.1.1.tar.gz
  • Upload date:
  • Size: 275.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.14

File hashes

Hashes for ftw.trash-1.1.1.tar.gz
Algorithm Hash digest
SHA256 10c380e9790f0f1505de247c55ad2213defc2e0bab69edc5c7863b7b398bf94d
MD5 ade11c98125848eea709cda960d4ead6
BLAKE2b-256 3295a54847e2d044788780e769b9aa50a86daa7d96d0c543ba5da53103616987

See more details on using hashes here.

Release history Release notifications | RSS feed

1.7.4

1 file

1.7.3

1 file

1.7.2

1 file

1.7.1

1 file

1.7.0

1 file

1.6.0

1 file

1.5.1

1 file

1.5.0

1 file

1.4.1

1 file

1.3.1

1 file

1.3.0

1 file

1.2.1

1 file

1.2.0

1 file

This release

1.1.1 This release

1 file

1.1.0

1 file

1.0.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page