equal
deleted
inserted
replaced
63 category = 'integrity' |
63 category = 'integrity' |
64 |
64 |
65 |
65 |
66 class CheckCardinalityHook(IntegrityHook): |
66 class CheckCardinalityHook(IntegrityHook): |
67 """check cardinalities are satisfied""" |
67 """check cardinalities are satisfied""" |
68 __id__ = 'checkcard' |
68 __regid__ = 'checkcard' |
69 events = ('after_add_entity', 'before_delete_relation') |
69 events = ('after_add_entity', 'before_delete_relation') |
70 |
70 |
71 def __call__(self): |
71 def __call__(self): |
72 getattr(self, self.event)() |
72 getattr(self, self.event)() |
73 |
73 |
142 """check the relation satisfy its constraints |
142 """check the relation satisfy its constraints |
143 |
143 |
144 this is delayed to a precommit time operation since other relation which |
144 this is delayed to a precommit time operation since other relation which |
145 will make constraint satisfied may be added later. |
145 will make constraint satisfied may be added later. |
146 """ |
146 """ |
147 __id__ = 'checkconstraint' |
147 __regid__ = 'checkconstraint' |
148 events = ('after_add_relation',) |
148 events = ('after_add_relation',) |
149 |
149 |
150 def __call__(self): |
150 def __call__(self): |
151 constraints = self._cw.schema_rproperty(self.rtype, self.eidfrom, self.eidto, |
151 constraints = self._cw.schema_rproperty(self.rtype, self.eidfrom, self.eidto, |
152 'constraints') |
152 'constraints') |
154 _CheckConstraintsOp(self._cw, constraints=constraints, |
154 _CheckConstraintsOp(self._cw, constraints=constraints, |
155 rdef=(self.eidfrom, self.rtype, self.eidto)) |
155 rdef=(self.eidfrom, self.rtype, self.eidto)) |
156 |
156 |
157 |
157 |
158 class CheckUniqueHook(IntegrityHook): |
158 class CheckUniqueHook(IntegrityHook): |
159 __id__ = 'checkunique' |
159 __regid__ = 'checkunique' |
160 events = ('before_add_entity', 'before_update_entity') |
160 events = ('before_add_entity', 'before_update_entity') |
161 |
161 |
162 def __call__(self): |
162 def __call__(self): |
163 entity = self.entity |
163 entity = self.entity |
164 eschema = entity.e_schema |
164 eschema = entity.e_schema |
192 |
192 |
193 |
193 |
194 class DeleteCompositeOrphanHook(IntegrityHook): |
194 class DeleteCompositeOrphanHook(IntegrityHook): |
195 """delete the composed of a composite relation when this relation is deleted |
195 """delete the composed of a composite relation when this relation is deleted |
196 """ |
196 """ |
197 __id__ = 'deletecomposite' |
197 __regid__ = 'deletecomposite' |
198 events = ('before_delete_relation',) |
198 events = ('before_delete_relation',) |
199 |
199 |
200 def __call__(self): |
200 def __call__(self): |
201 composite = self._cw.schema_rproperty(self.rtype, self.eidfrom, self.eidto, |
201 composite = self._cw.schema_rproperty(self.rtype, self.eidfrom, self.eidto, |
202 'composite') |
202 'composite') |
209 |
209 |
210 |
210 |
211 class DontRemoveOwnersGroupHook(IntegrityHook): |
211 class DontRemoveOwnersGroupHook(IntegrityHook): |
212 """delete the composed of a composite relation when this relation is deleted |
212 """delete the composed of a composite relation when this relation is deleted |
213 """ |
213 """ |
214 __id__ = 'checkownersgroup' |
214 __regid__ = 'checkownersgroup' |
215 __select__ = IntegrityHook.__select__ & entity_implements('CWGroup') |
215 __select__ = IntegrityHook.__select__ & entity_implements('CWGroup') |
216 events = ('before_delete_entity', 'before_update_entity') |
216 events = ('before_delete_entity', 'before_update_entity') |
217 |
217 |
218 def __call__(self): |
218 def __call__(self): |
219 if self.event == 'before_delete_entity' and self.entity.name == 'owners': |
219 if self.event == 'before_delete_entity' and self.entity.name == 'owners': |
226 self.entity['name'] = newname |
226 self.entity['name'] = newname |
227 |
227 |
228 |
228 |
229 class TidyHtmlFields(IntegrityHook): |
229 class TidyHtmlFields(IntegrityHook): |
230 """tidy HTML in rich text strings""" |
230 """tidy HTML in rich text strings""" |
231 __id__ = 'htmltidy' |
231 __regid__ = 'htmltidy' |
232 events = ('before_add_entity', 'before_update_entity') |
232 events = ('before_add_entity', 'before_update_entity') |
233 |
233 |
234 def __call__(self): |
234 def __call__(self): |
235 entity = self.entity |
235 entity = self.entity |
236 metaattrs = entity.e_schema.meta_attributes() |
236 metaattrs = entity.e_schema.meta_attributes() |
245 entity[attr] = soup2xhtml(value, self._cw.encoding) |
245 entity[attr] = soup2xhtml(value, self._cw.encoding) |
246 |
246 |
247 |
247 |
248 class StripCWUserLoginHook(IntegrityHook): |
248 class StripCWUserLoginHook(IntegrityHook): |
249 """ensure user logins are stripped""" |
249 """ensure user logins are stripped""" |
250 __id__ = 'stripuserlogin' |
250 __regid__ = 'stripuserlogin' |
251 __select__ = IntegrityHook.__select__ & entity_implements('CWUser') |
251 __select__ = IntegrityHook.__select__ & entity_implements('CWUser') |
252 events = ('before_add_entity', 'before_update_entity',) |
252 events = ('before_add_entity', 'before_update_entity',) |
253 |
253 |
254 def __call__(self): |
254 def __call__(self): |
255 user = self.entity |
255 user = self.entity |