Skip to content

Instantly share code, notes, and snippets.

@lukasgraf
Created December 9, 2013 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukasgraf/7880348 to your computer and use it in GitHub Desktop.
Save lukasgraf/7880348 to your computer and use it in GitHub Desktop.
Patching Dexterity Container to use AddPortalContent for manage_pasteObjects
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