983 self._cw.execute('DELETE CWRelation X WHERE X relation_type Y, Y eid %(x)s', |
983 self._cw.execute('DELETE CWRelation X WHERE X relation_type Y, Y eid %(x)s', |
984 {'x': self.entity.eid}) |
984 {'x': self.entity.eid}) |
985 MemSchemaCWRTypeDel(self._cw, rtype=name) |
985 MemSchemaCWRTypeDel(self._cw, rtype=name) |
986 |
986 |
987 |
987 |
988 class AfterAddCWRTypeHook(DelCWRTypeHook): |
988 class AfterAddCWRTypeHook(SyncSchemaHook): |
989 """after a CWRType entity has been added: |
989 """after a CWRType entity has been added: |
990 * register an operation to add the relation type to the instance's |
990 * register an operation to add the relation type to the instance's |
991 schema on commit |
991 schema on commit |
992 |
992 |
993 We don't know yet this point if a table is necessary |
993 We don't know yet this point if a table is necessary |
994 """ |
994 """ |
995 __regid__ = 'syncaddcwrtype' |
995 __regid__ = 'syncaddcwrtype' |
|
996 __select__ = SyncSchemaHook.__select__ & is_instance('CWRType') |
996 events = ('after_add_entity',) |
997 events = ('after_add_entity',) |
997 |
998 |
998 def __call__(self): |
999 def __call__(self): |
999 entity = self.entity |
1000 entity = self.entity |
1000 rtypedef = ybo.RelationType(name=entity.name, |
1001 rtypedef = ybo.RelationType(name=entity.name, |
1003 symmetric=entity.cw_edited.get('symmetric', False), |
1004 symmetric=entity.cw_edited.get('symmetric', False), |
1004 eid=entity.eid) |
1005 eid=entity.eid) |
1005 MemSchemaCWRTypeAdd(self._cw, rtypedef=rtypedef) |
1006 MemSchemaCWRTypeAdd(self._cw, rtypedef=rtypedef) |
1006 |
1007 |
1007 |
1008 |
1008 class BeforeUpdateCWRTypeHook(DelCWRTypeHook): |
1009 class BeforeUpdateCWRTypeHook(SyncSchemaHook): |
1009 """check name change, handle final""" |
1010 """check name change, handle final""" |
1010 __regid__ = 'syncupdatecwrtype' |
1011 __regid__ = 'syncupdatecwrtype' |
|
1012 __select__ = SyncSchemaHook.__select__ & is_instance('CWRType') |
1011 events = ('before_update_entity',) |
1013 events = ('before_update_entity',) |
1012 |
1014 |
1013 def __call__(self): |
1015 def __call__(self): |
1014 entity = self.entity |
1016 entity = self.entity |
1015 check_valid_changes(self._cw, entity) |
1017 check_valid_changes(self._cw, entity) |