hooks/syncschema.py
changeset 9963 5531f5577b50
parent 9962 64b573d54133
child 9964 f4a3ee05cf9d
equal deleted inserted replaced
9962:64b573d54133 9963:5531f5577b50
   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 AfterAddCWComputedRTypeHook(SyncSchemaHook):
       
   989     """after a CWComputedRType entity has been added:
       
   990     * register an operation to add the relation type to the instance's
       
   991       schema on commit
       
   992 
       
   993     We don't know yet this point if a table is necessary
       
   994     """
       
   995     __regid__ = 'syncaddcwcomputedrtype'
       
   996     __select__ = SyncSchemaHook.__select__ & is_instance('CWComputedRType')
       
   997     events = ('after_add_entity',)
       
   998 
       
   999     def __call__(self):
       
  1000         entity = self.entity
       
  1001         rtypedef = ybo.ComputedRelation(name=entity.name,
       
  1002                                         eid=entity.eid,
       
  1003                                         rule=entity.rule)
       
  1004         MemSchemaCWRTypeAdd(self._cw, rtypedef=rtypedef)
       
  1005 
       
  1006 
   988 class AfterAddCWRTypeHook(SyncSchemaHook):
  1007 class AfterAddCWRTypeHook(SyncSchemaHook):
   989     """after a CWRType entity has been added:
  1008     """after a CWRType entity has been added:
   990     * register an operation to add the relation type to the instance's
  1009     * register an operation to add the relation type to the instance's
   991       schema on commit
  1010       schema on commit
   992 
  1011