Created
December 9, 2013 20:37
-
-
Save lukasgraf/7880348 to your computer and use it in GitHub Desktop.
Patching Dexterity Container to use AddPortalContent for manage_pasteObjects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from plone.dexterity.content import Container | |
# Change permission for manage_pasteObjects to "Add portal content" | |
# See https://dev.plone.org/ticket/9177 | |
# XXX Find a way to do this without patching __ac_permissions__ directly | |
def drop_protected_attr_from_ac_permissions(attribute, classobj): | |
new_mappings = [] | |
for mapping in Container.__ac_permissions__: | |
perm, attrs = mapping | |
if not attribute in attrs: | |
new_mappings.append(mapping) | |
else: | |
modified_attrs = tuple([a for a in attrs if not a == attribute]) | |
modified_mapping = (perm, modified_attrs) | |
new_mappings.append(modified_mapping) | |
classobj.__ac_permissions__ = tuple(new_mappings) | |
drop_protected_attr_from_ac_permissions('manage_pasteObjects', Container) | |
sec = ClassSecurityInfo() | |
sec.declareProtected(Products.CMFCore.permissions.AddPortalContent, | |
'manage_pasteObjects') | |
sec.apply(Container) | |
InitializeClass(Container) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment