hooks/syncschema.py
changeset 3431 6944a92c16f2
parent 3410 47832374cf14
child 3536 f6c9a5df80fb
equal deleted inserted replaced
3423:d1356e008b19 3431:6944a92c16f2
   869     __select__ = SyncSchemaHook.__select__ & entity_implements('CWRType')
   869     __select__ = SyncSchemaHook.__select__ & entity_implements('CWRType')
   870     events = ('before_delete_entity',)
   870     events = ('before_delete_entity',)
   871 
   871 
   872     def __call__(self):
   872     def __call__(self):
   873         name = self.entity.name
   873         name = self.entity.name
   874         if name in CORE_ETYPES:
   874         if name in CORE_RTYPES:
   875             raise ValidationError(self.entity.eid, {None: self._cw._('can\'t be deleted')})
   875             raise ValidationError(self.entity.eid, {None: self._cw._('can\'t be deleted')})
   876         # delete relation definitions using this relation type
   876         # delete relation definitions using this relation type
   877         self._cw.execute('DELETE CWAttribute X WHERE X relation_type Y, Y eid %(x)s',
   877         self._cw.execute('DELETE CWAttribute X WHERE X relation_type Y, Y eid %(x)s',
   878                         {'x': self.entity.eid})
   878                         {'x': self.entity.eid})
   879         self._cw.execute('DELETE CWRelation X WHERE X relation_type Y, Y eid %(x)s',
   879         self._cw.execute('DELETE CWRelation X WHERE X relation_type Y, Y eid %(x)s',