162 """ |
162 """ |
163 __regid__ = 'checkattrconstraint' |
163 __regid__ = 'checkattrconstraint' |
164 events = ('after_add_entity', 'after_update_entity') |
164 events = ('after_add_entity', 'after_update_entity') |
165 |
165 |
166 def __call__(self): |
166 def __call__(self): |
167 schema = self._cw.vreg.schema |
167 eschema = entity.eschema |
168 entity = self.entity |
168 for attr in self.entity.edited_attributes: |
169 for attr in entity.edited_attributes: |
169 if eschema.subjrels[attr].final: |
170 if schema.rschema(attr).final: |
170 constraints = [c for c in eschema.rdef(attr).constraints |
171 constraints = [c for c in entity.e_schema.rdef(attr).constraints |
|
172 if isinstance(c, (RQLUniqueConstraint, RQLConstraint))] |
171 if isinstance(c, (RQLUniqueConstraint, RQLConstraint))] |
173 if constraints: |
172 if constraints: |
174 _CheckConstraintsOp(self._cw, constraints=constraints, |
173 _CheckConstraintsOp(self._cw, constraints=constraints, |
175 rdef=(entity.eid, attr, None)) |
174 rdef=(self.entity.eid, attr, None)) |
176 |
175 |
177 |
176 |
178 class CheckUniqueHook(UserIntegrityHook): |
177 class CheckUniqueHook(UserIntegrityHook): |
179 __regid__ = 'checkunique' |
178 __regid__ = 'checkunique' |
180 events = ('before_add_entity', 'before_update_entity') |
179 events = ('before_add_entity', 'before_update_entity') |