| 1516 | for perm in rule.permissions: |
| 1517 | entity._access_rules_[perm].add(rule) |
| 1518 | def exclude(rule, *args): |
| 1519 | for arg in args: |
| 1520 | if isinstance(arg, EntityMeta): |
| 1521 | entity = arg |
| 1522 | rule.entities_to_exclude.add(entity) |
| 1523 | rule.entities_to_exclude.update(entity._subclasses_) |
| 1524 | elif isinstance(arg, Attribute): |
| 1525 | attr = arg |
| 1526 | if attr.pk_offset is not None: throw(TypeError, 'Primary key attribute %s cannot be excluded' % attr) |
| 1527 | rule.attrs_to_exclude.add(attr) |
| 1528 | else: throw(TypeError, 'Entity or attribute expected. Got: %r' % arg) |
| 1529 | |
| 1530 | @cut_traceback |
| 1531 | def has_perm(user, perm, x): |