Browse Source

LeObject: method to instanciate from a dict of data

ArnAud 9 years ago
parent
commit
94e6cbf81e
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      leapi/leobject.py

+ 6
- 1
leapi/leobject.py View File

@@ -84,7 +84,12 @@ class _LeObject(_LeCrud):
84 84
         if uid not in cls._me_uid:
85 85
             raise KeyError("No LeType or LeClass child classes with uid '%d'"%uid)
86 86
         return cls._me_uid[uid]
87
-    
87
+
88
+    ## @brief instanciate the relevant lodel object using a dict of datas
89
+    @classmethod
90
+    def object_from_data(cls, datas):
91
+        return cls.uid2leobj(datas['type_id'])(**datas)
92
+
88 93
     @classmethod
89 94
     def fieldtypes(cls):
90 95
         if cls._fieldtypes_all is None:

Loading…
Cancel
Save