Having defined roles, in our case being Administrator, Editor or Viewer, we can assign one or more of these roles to principals as we create them in our PrincipalsFolder.  For example, we might say "Bob is an Editor, Sue is an Administrator, and Pete is an Administrator as well as an Editor".

The way this is done, is by using the sites Role Manager:

        roleMgr = IPrincipalRoleManager(grok.getSite())
        uid = self.getIdByLogin('admin')
        roleMgr.assignRoleToPrincipal('gfn.Administrator', 'gfn.'+uid)

In other words, we say that principal 'gfn.'+uid is a 'gfn.Administrator'

 

We can assign as many roles to principals as is needed.  Note that we use a prefix of 'gfn.' before identities like principals and roles.  The reason being that by doing so we can keep the name space separate from other projects.  We shall see later where prefixes are specified for the plugins.

 

Grok 4 Noobs

Defining and Assigning Roles