用python 代码给 Plone增加角色

用python 代码给 Plone增加角色
portal._addRole(new_role)
try:
    acl_users.portal_role_manager.addRole(new_role)
except:
    pass
参考链接:http://repositorio.interlegis.gov.br/ILSAAP/trunk/InstallUtils/installers/installRoles.py
应用例子:https://github.com/simahawk/collective.blueprint.usersandgroups/blob/master/collective/blueprint/usersandgroups/blueprint.py#L62
方法二:
## Roles are store on __ac_roles__ attribute of object.
roles = list(portal.__ac_roles__)
roles += 'yournewrole'
portal.__ac_roles__ = tuple(roles)


设置