Browse Source

LeRelation: first draft of method to instanciate from a dict of data

ArnAud 9 years ago
parent
commit
d509fdf196
1 changed files with 10 additions and 3 deletions
  1. 10
    3
      leapi/lerelation.py

+ 10
- 3
leapi/lerelation.py View File

@@ -16,8 +16,8 @@ class _LeRelation(lecrud._LeCrud):
16 16
     ## @brief Stores the list of fieldtypes that are common to all relations
17 17
     _rel_fieldtypes = dict()
18 18
 
19
-    def __init__(self, rel_id, **kwargs):
20
-        self.id_relation = rel_id
19
+    def __init__(self, id_relation, **kwargs):
20
+        self.id_relation = id_relation
21 21
     
22 22
     ## @brief Forge a filter to match the superior
23 23
     @classmethod
@@ -41,7 +41,14 @@ class _LeRelation(lecrud._LeCrud):
41 41
         if cls.implements_lerel2type():
42 42
             rel_ft.update(cls._rel_attr_fieldtypes)
43 43
         return rel_ft
44
-    
44
+
45
+    ## @brief instanciate the relevant lodel object using a dict of datas
46
+    @classmethod
47
+    def object_from_data(cls, datas):
48
+        if 'nature' in datas:
49
+            return cls.name2class('LeHierarch')(**datas)
50
+        return "To implement !"
51
+
45 52
     @classmethod
46 53
     def _prepare_relational_fields(cls, field):
47 54
         return lecrud.LeApiQueryError("Relational field '%s' given but %s doesn't is not a LeObject" % (field,

Loading…
Cancel
Save