hooks/syncschema.py
changeset 9962 64b573d54133
parent 9960 6359f3121f3f
child 9963 5531f5577b50
equal deleted inserted replaced
9961:cef58bd36f7b 9962:64b573d54133
  1061                 cnx.execute('DELETE X %s Y WHERE X is %s, Y is %s'
  1061                 cnx.execute('DELETE X %s Y WHERE X is %s, Y is %s'
  1062                                 % (rschema, subjschema, objschema))
  1062                                 % (rschema, subjschema, objschema))
  1063         RDefDelOp(cnx, rdef=rdef)
  1063         RDefDelOp(cnx, rdef=rdef)
  1064 
  1064 
  1065 
  1065 
       
  1066 # CWComputedRType hooks #######################################################
       
  1067 
       
  1068 class DelCWComputedRTypeHook(SyncSchemaHook):
       
  1069     """before deleting a CWComputedRType entity:
       
  1070     * check that we don't remove a core relation type
       
  1071     * instantiate an operation to delete the relation type on commit
       
  1072     """
       
  1073     __regid__ = 'syncdelcwcomputedrtype'
       
  1074     __select__ = SyncSchemaHook.__select__ & is_instance('CWComputedRType')
       
  1075     events = ('before_delete_entity',)
       
  1076 
       
  1077     def __call__(self):
       
  1078         name = self.entity.name
       
  1079         if name in CORE_TYPES:
       
  1080             raise validation_error(self.entity, {None: _("can't be deleted")})
       
  1081         MemSchemaCWRTypeDel(self._cw, rtype=name)
       
  1082 
       
  1083 
  1066 # CWAttribute / CWRelation hooks ###############################################
  1084 # CWAttribute / CWRelation hooks ###############################################
  1067 
  1085 
  1068 class AfterAddCWAttributeHook(SyncSchemaHook):
  1086 class AfterAddCWAttributeHook(SyncSchemaHook):
  1069     __regid__ = 'syncaddcwattribute'
  1087     __regid__ = 'syncaddcwattribute'
  1070     __select__ = SyncSchemaHook.__select__ & is_instance('CWAttribute')
  1088     __select__ = SyncSchemaHook.__select__ & is_instance('CWAttribute')