hooks/syncschema.py
changeset 8718 9e7847dcbd94
parent 8696 0bb18407c053
parent 8715 ab0cd0765076
child 8821 c4aa23af0baa
--- a/hooks/syncschema.py	Tue Mar 05 15:37:37 2013 +0100
+++ b/hooks/syncschema.py	Mon Mar 11 18:37:01 2013 +0100
@@ -244,7 +244,7 @@
     * create the necessary table
     * set creation_date and modification_date by creating the necessary
       CWAttribute entities
-    * add owned_by relation by creating the necessary CWRelation entity
+    * add <meta rtype> relation by creating the necessary CWRelation entity
     """
     entity = None # make pylint happy
 
@@ -270,9 +270,16 @@
             except KeyError:
                 self.critical('rtype %s was not handled at cwetype creation time', rtype)
                 continue
+            if not rschema.rdefs:
+                self.warning('rtype %s has no relation definition yet', rtype)
+                continue
             sampletype = rschema.subjects()[0]
             desttype = rschema.objects()[0]
-            rdef = copy(rschema.rdef(sampletype, desttype))
+            try:
+                rdef = copy(rschema.rdef(sampletype, desttype))
+            except KeyError:
+                # this combo does not exist because this is not a universal META_RTYPE
+                continue
             rdef.subject = _MockEntity(eid=entity.eid)
             mock = _MockEntity(eid=None)
             ss.execschemarql(session.execute, mock, ss.rdef2rql(rdef, cmap, gmap))