Created
June 20, 2014 06:49
-
-
Save maethu/2d1160e2dc93b032d1df to your computer and use it in GitHub Desktop.
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 AccessControl.SecurityManagement import newSecurityManager | |
from Acquisition import aq_inner | |
from Acquisition import aq_parent | |
from Products.CMFCore.utils import getToolByName | |
from Testing.makerequest import makerequest | |
from zope.component.hooks import setSite | |
import transaction | |
app = globals()['app'] | |
# we need to get a super user security and a request | |
user = app.acl_users.getUser('zopemaster') | |
user = user.__of__(app.acl_users) | |
newSecurityManager(app, user) | |
app = makerequest(app) | |
globals()['app'] = app | |
# register the site | |
globals()['platform'] = app.to.plone | |
setSite(platform) | |
def fix(obj): | |
for item in obj.ac_inherited_permissions(1): | |
permission = item[0] | |
obj.manage_permission(permission, roles=[], acquire=True) | |
obj.reindexObjectSecurity() | |
query = {'portal_type': ['TextBlock']} | |
for brain in platform.portal_catalog(query): | |
obj = brain.getObject() | |
fix(obj) | |
print "Fixed permissions of %s" % obj.absolute_url() | |
print "COMITTING" | |
transaction.commit() | |
print "COMITTED" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment