Power of bits

Report a typo

Assuming, each permission is power of two, match the bitwise operators to their typical use cases in managing permissions:

Fill in the gaps with the relevant elements
class Role(db.Model):
    #...

    def add_permission(self,permission):                       
        if not self.has_permission(permission):
            

    def remove_permission(self, permission):
        if self.has_permission(permission):
            

    def reset_permissions(self):
               

    def has_permission(self, permission):
        return 
self.permissions = 0(self.permissions & permission) == permissionself.permissions &= ~permissionself.permissions |= permission
___

Create a free account to access the full topic