فهرست منبع

Fix bug where creation of slot defined in super-class fails + clearer error message

Joeri Exelmans 1 سال پیش
والد
کامیت
98ae637eea
2فایلهای تغییر یافته به همراه7 افزوده شده و 5 حذف شده
  1. 1 1
      framework/conformance.py
  2. 6 4
      services/od.py

+ 1 - 1
framework/conformance.py

@@ -35,7 +35,7 @@ class Conformance:
         self.scd_model = UUID(state.read_value(type_model_id))
         self.model = model
         self.type_model = type_model
-        self.constraint_check_subtypes = constraint_check_subtypes # for a class-level constraint, also check the constraint on the subtypes of that class?
+        self.constraint_check_subtypes = constraint_check_subtypes # for a class-level constraint, also check the constraint on the subtypes of that class? In other words, are constraints inherited.
         self.type_mapping: Dict[str, str] = {}
         self.model_names = {
             # map model elements to their names to prevent iterating too much

+ 6 - 4
services/od.py

@@ -69,9 +69,11 @@ class OD:
     def create_slot(self, attr_name: str, object_name: str, target_name: str):
         class_name = self.get_class_of_object(object_name)
         attr_link_name = self.get_attr_link_name(class_name, attr_name)
+        if attr_link_name == None:
+            raise Exception(f"Failed to get link name for attribute '{attr_name}' of object '{object_name}'")
         # An attribute-link is indistinguishable from an ordinary link:
-        slot_id = self.create_link(
-            get_slot_link_name(object_name, attr_name),
+        slot_link_name = get_slot_link_name(object_name, attr_name)
+        slot_id = self.create_link(slot_link_name,
             attr_link_name, object_name, target_name)
         return slot_id
 
@@ -154,9 +156,9 @@ class OD:
             return assoc_name
         else:
             # look for attribute in the super-types
-            conf = Conformance(self.bottom.state, self.type_model, get_scd_mm(self.bottom))
+            conf = Conformance(self.bottom.state, self.model, self.type_model)
             conf.precompute_sub_types() # only need to know about subtypes
-            super_types = (s for s in conf.sub_types if class_name in conf.sub_types[s])
+            super_types = [s for s in conf.sub_types if class_name in conf.sub_types[s]]
             for s in super_types:
                 assoc_name = f"{s}_{attr_name}"
                 if len(self.bottom.read_outgoing_elements(self.type_model, assoc_name)) == 1: