Exemplo n.º 1
0
    def __init__(self, user):
        acl = RegistryProxy(Registry())
        self.identity = IdentityContext(acl, lambda: user.get_roles())

        role_list = [
            getattr(AUTH.ROLE, role) for role in dir(AUTH.ROLE)
            if "__" not in role
        ]
        for role in role_list:
            acl.add_role(role)

        for res in AUTH.RESOURCES:
            acl.add_resource(res)

        for a in AUTH.ALLOWS:
            acl.allow(a[0], a[1][2],
                      a[2])  # пример: ("админ", "Поиск по коду", "чек")

        for d in AUTH.DENYS:
            acl.deny(d[0], d[1][2], d[2])