4teamwork/collective.deletepermission — pull request #3 by jone (2013-05-16 14:01:36+00:00)
Title: Cannot create objects without delete permission

Dependening on the workflow configuration there are situation where the user has no delete permission but should be able to create objects anyway. This can occur when the created object has no workflow and the user has no delete permission on the parent.

I've added a failing test to the pull request (add some docs to another test).

A possible solution would be to patch the `processForm` method of the `BaseObject` class in `Products.Archetypes.BaseObject.py`, with something like this:

```patch
Changes from master to stash
Modified BaseObject.py
diff --git a/BaseObject.py b/BaseObject.py
index 8788a64..7cb0baf 100755
--- a/BaseObject.py
+++ b/BaseObject.py
@@ -655,7 +655,20 @@ class BaseObject(Referenceable):
REQUEST=REQUEST, values=values)
self.unmarkCreationFlag()
if self._at_rename_after_creation and is_new_object:
- self._renameAfterCreation(check_auto_id=True)
+ # --- patch
+ from AccessControl import getSecurityManager
+ from AccessControl.SecurityManagement import newSecurityManager
+ from AccessControl.SecurityManagement import setSecurityManager
+ from AccessControl.SpecialUsers import system
+ old_security_manager = getSecurityManager()
+ newSecurityManager(self.REQUEST, system)
+ try:
+ # --- ori
+ self._renameAfterCreation(check_auto_id=True)
+ # / --- ori
+ finally:
+ setSecurityManager(old_security_manager)
+ # / --- patch

# Post create/edit hooks
if is_new_object:
```

Patches (Plone 4.3): https://github.com/plone/Products.Archetypes/blob/1.8.7/Products/Archetypes/BaseObject.py#L650

This is experimental, patching the egg. If the patch is good it needs to be rewritten.

@buchi please take a look as discussed