## 1.2.8 Using Roles

Insetead of using auth levels, you might prefer to use roles. For example you could have `basicUser` and `administrator` as different roles. This can be emulated using bitwise operations. Thanks to Cecil Westerhof for pointing this out. Consider the variables below:

    basicUser = 1
    administrator = 2
    role3 = 4
    role4 = 8

Someone with `basicUser` and `administrator` would have accessLevel 5. Someone with `basicUser`, `administrator` and `role3` would have accessLevel 11.

To determine if someone has access to a particular role you can evaluate `roleX & AccessLevel`. If the result is `True` the user has access to the particular role. For example to determine if a user is an administrator we could do the following:

    if administrator & user.accessLevel:
        print "User is an administrator"
    else:
        print "User is not an administrator"