RoleUser

The RoleUser class.

class UserKit.RoleUser.RoleUser(manager=None, name=None, password=None)

Bases: User

In conjunction with Role, provides role-based users and security.

See the doc for playsRole() for an example.

Note that this class plays nicely with both Role and HierRole, e.g., no “HierRoleUser” is needed when making use of HierRoles.

See also:
  • class Role

  • class HierRole

__init__(manager=None, name=None, password=None)
addRoles(listOfRoles)

Add additional roles for the user.

Each role in the list may be a valid role name or a Role object.

creationTime()
externalId()
isActive()
lastAccessTime()
lastLoginTime()
login(password, fromMgr=0)

Return self if the login is successful and None otherwise.

logout(fromMgr=False)
manager()
name()
password()
playsRole(roleOrName)

Check whether the user plays the given role.

More specifically, if any of the user’s roles return true for role.playsRole(otherRole), this method returns True.

The application of this popular method often looks like this:
if user.playsRole(‘admin’):

self.displayAdminMenuItems()

roles()

Return a direct list of the user’s roles.

Do not modify.

serialNum()
setManager(manager)

Set the manager, which can only be done once.

setName(name)

Set the name, which can only be done once.

setPassword(password)
setRoles(listOfRoles)

Set all the roles for the user.

Each role in the list may be a valid role name or a Role object.

Implementation note: depends on addRoles().

setSerialNum(serialNum)
wasAccessed()