How do I create a new role in code?
Raphael Ritz
r.ritz at biologie.hu-berlin.de
Mon Dec 3 10:48:05 UTC 2007
Sean Fulmer wrote:
[..]
> portal=getToolByName(self,'portal_url').getPortalObject()
> roles=list(portal.__ac_roles__)
> for role in ('CustomRole1','CustomRole2',):
> if role not in roles:
> roles.append(role)
> portal.__ac_roles__=tuple(roles)
>
> Don't really know if it will work for you, but I guess it's worth a shot :)
>
Yup. Or somewhat shorter:
def addRole(self, out, role):
if role not in self.__ac_roles__:
self._addRole(role)
out.write("Added the '%s' role to the portal.\n" % role)
That's at least how I did it here:
http://svn.plone.org/svn/collective/LockingWorkflow/trunk/Extensions/Install.py
Raphael
> --
> Sean
More information about the Product-Developers
mailing list