Procházet zdrojové kódy

LeObject: method to instanciate from a dict of data

ArnAud před 9 roky
rodič
revize
94e6cbf81e
1 změnil soubory, kde provedl 6 přidání a 1 odebrání
  1. 6
    1
      leapi/leobject.py

+ 6
- 1
leapi/leobject.py Zobrazit soubor

@@ -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…
Zrušit
Uložit