hooks/syncschema.py
changeset 9963 5531f5577b50
parent 9962 64b573d54133
child 9964 f4a3ee05cf9d
--- a/hooks/syncschema.py	Thu Aug 28 07:55:33 2014 +0200
+++ b/hooks/syncschema.py	Thu Aug 28 08:02:15 2014 +0200
@@ -985,6 +985,25 @@
         MemSchemaCWRTypeDel(self._cw, rtype=name)
 
 
+class AfterAddCWComputedRTypeHook(SyncSchemaHook):
+    """after a CWComputedRType entity has been added:
+    * register an operation to add the relation type to the instance's
+      schema on commit
+
+    We don't know yet this point if a table is necessary
+    """
+    __regid__ = 'syncaddcwcomputedrtype'
+    __select__ = SyncSchemaHook.__select__ & is_instance('CWComputedRType')
+    events = ('after_add_entity',)
+
+    def __call__(self):
+        entity = self.entity
+        rtypedef = ybo.ComputedRelation(name=entity.name,
+                                        eid=entity.eid,
+                                        rule=entity.rule)
+        MemSchemaCWRTypeAdd(self._cw, rtypedef=rtypedef)
+
+
 class AfterAddCWRTypeHook(SyncSchemaHook):
     """after a CWRType entity has been added:
     * register an operation to add the relation type to the instance's