浏览代码

Added the management of allowed_classes in Reference

Roland Haroutiounian 8 年前
父节点
当前提交
1c1d353719
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4
    1
      lodel/leapi/datahandlers/reference.py

+ 4
- 1
lodel/leapi/datahandlers/reference.py 查看文件

@@ -20,7 +20,7 @@ class Reference(FieldDataHandler):
20 20
     ## @brief checks if the data value is valid
21 21
     # @param value
22 22
     # @return
23
-    def check_data_value(self, value):
23
+    def _check_data_value(self, value):
24 24
 
25 25
         if not isinstance(value, self._refs_class):
26 26
             return value, "The reference should be an instance of %s, %s gotten" % (self._refs_class, value.__class__)
@@ -35,4 +35,7 @@ class Reference(FieldDataHandler):
35 35
             if not isinstance(related, EmClass):
36 36
                 return value, "The reference %s should be an instance of EmClass, %s gotten" % (related.display_name,
37 37
                                                                                                 related.__class__)
38
+            if self.allowed_classes is not None and related.__class__.display_name not in self.allowed_classes:
39
+                return value, "The reference %s should be an instance of either one of those classes : %s, %s gotten" % \
40
+                              (related.display_name, self.allowed_classes, related.__class__)
38 41
         return value, None

正在加载...
取消
保存