def getActionsRoot(self, identifier, **options): ''' @see: IUserRbacService.getActions ''' rbacId = self.findRbacId(identifier) if rbacId is None: return emptyCollection(**options) sql = self.session().query(distinct(RightAction.actionPath)) sql = sql.filter(RightAction.categoryId.in_(self.sqlRights(rbacId))) # @UndefinedVariable return processCollection(listRootPaths(path for path, in sql.all()), **options)
def getRights(self, identifier, typeName=None, q=None, **options): ''' @see: IRbacPrototype.getRights ''' rbacId = self.findRbacId(identifier) if rbacId is None: return emptyCollection(**options) sql = self.sqlRights(rbacId, typeName) if q: assert isinstance(q, QRight), 'Invalid query %s' % q sql = buildQuery(sql, q, RightMapped) return iterateCollection(sql, **options)
def getSubActions(self, identifier, parentPath, **options): ''' @see: IUserRbacService.getSubActions ''' assert isinstance(parentPath, str), 'Invalid parent path %s' % parentPath rbacId = self.findRbacId(identifier) if rbacId is None: return emptyCollection(**options) sql = self.session().query(distinct(RightAction.actionPath)) sql = sql.filter(RightAction.categoryId.in_(self.sqlRights(rbacId))) # @UndefinedVariable sql = sql.filter(RightAction.actionPath.like('%s.%%' % parentPath)) # @UndefinedVariable return processCollection(listRootPaths((path for path, in sql.all()), len(parentPath) + 1), **options)
def getRoles(self, identifier, q=None, **options): ''' @see: IRbacPrototype.getRoles ''' rbacId = self.findRbacId(identifier) if rbacId is None: return emptyCollection(**options) sql = self.session().query(RoleMapped.Name) sql = sql.join(Child, Child.roleId == RoleMapped.id) sql = sql.join(Parent, and_(Child.left >= Parent.left, Child.right <= Parent.right)) sql = sql.join(RbacRole, and_(RbacRole.roleId == Parent.roleId, RbacRole.rbacId == rbacId)) sql = sql.order_by(RoleMapped.Name) if q: assert isinstance(q, QRole), 'Invalid query %s' % q sql = buildQuery(sql, q, RoleMapped) return iterateCollection(sql, **options)
def getRoles(self, identifier, q=None, **options): ''' @see: IRbacPrototype.getRoles ''' rbacId = self.findRbacId(identifier) if rbacId is None: return emptyCollection(**options) sql = self.session().query(RoleMapped.Name) sql = sql.join(Child, Child.roleId == RoleMapped.id) sql = sql.join( Parent, and_(Child.left >= Parent.left, Child.right <= Parent.right)) sql = sql.join( RbacRole, and_(RbacRole.roleId == Parent.roleId, RbacRole.rbacId == rbacId)) sql = sql.order_by(RoleMapped.Name) if q: assert isinstance(q, QRole), 'Invalid query %s' % q sql = buildQuery(sql, q, RoleMapped) return iterateCollection(sql, **options)