|
@@ -59,43 +59,37 @@ class _LeObject(object):
|
59
|
59
|
letype,leclass = cls._prepare_targets(letype)
|
60
|
60
|
if letype is None:
|
61
|
61
|
raise ValueError("letype argument cannot be None")
|
62
|
|
- return cls._datasource.insert(letype, leclass, datas)
|
63
|
62
|
|
64
|
|
- ## @brief update an existing LeObject
|
65
|
|
- # @param lodel_id int | (int): lodel_id of the object(s) where to apply changes
|
66
|
|
- # @param data dict: dictionnary of field:value to save
|
67
|
|
- # @param update_filters string | (string): list of string of update filters
|
68
|
|
- # @return okay bool: True on success, it will raise on failure
|
69
|
|
- def update(self, lodel_id, data, update_filters=None):
|
70
|
|
- if not lodel_id:
|
71
|
|
- lodel_id = ()
|
72
|
|
- elif isinstance(lodel_id, int):
|
73
|
|
- lodel_id = (lodel_id)
|
74
|
|
-
|
75
|
|
- try:
|
76
|
|
- checked_data = self._check_data(data)
|
77
|
|
- datasource_filters = self._prepare_filters(update_filters)
|
78
|
|
- okay = self.datasource.update(lodel_id, checked_data, datasource_filters)
|
79
|
|
- except:
|
80
|
|
- raise
|
81
|
|
- return okay
|
82
|
|
-
|
83
|
|
- ## @brief delete an existing LeObject
|
84
|
|
- # @param lodel_id int | (int): lodel_id of the object(s) to delete
|
85
|
|
- # @param delete_filters string | (string): list of string of delete filters
|
86
|
|
- # @return okay bool: True on success, it will raise on failure
|
87
|
|
- def delete(self, lodel_id, delete_filters=None):
|
88
|
|
- if not lodel_id:
|
89
|
|
- lodel_id = ()
|
90
|
|
- elif isinstance(lodel_id, int):
|
91
|
|
- lodel_id = (lodel_id)
|
92
|
|
-
|
93
|
|
- try:
|
94
|
|
- datasource_filters = self._prepare_filters(delete_filters)
|
95
|
|
- okay = self.datasource.delete(lodel_id, datasource_filters)
|
96
|
|
- except:
|
97
|
|
- raise
|
98
|
|
- return okay
|
|
63
|
+ for data in datas:
|
|
64
|
+ letype.check_datas_or_raise(data, complete = True)
|
|
65
|
+
|
|
66
|
+ return cls._datasource.insert(letype, leclass, datas)
|
|
67
|
+
|
|
68
|
+ ## @brief Delete LeObjects given filters
|
|
69
|
+ # @param cls
|
|
70
|
+ # @param letype LeType|str : LeType child class or name
|
|
71
|
+ # @param leclass LeClass|str : LeClass child class or name
|
|
72
|
+ # @param filters list : list of filters (see @ref leobject_filters)
|
|
73
|
+ # @return bool
|
|
74
|
+ @classmethod
|
|
75
|
+ def delete(cls, letype, leclass, filters):
|
|
76
|
+ filters,relationnal_filters = leobject.leobject._LeObject._prepare_filters(filters, cls, cls._leclass)
|
|
77
|
+ letype, leclass = cls._prepare_targets(letype, leclass)
|
|
78
|
+ return cls._datasource(letype, leclass, filters, relationnal_filters)
|
|
79
|
+
|
|
80
|
+ ## @brief Update LeObjects given filters and datas
|
|
81
|
+ # @param cls
|
|
82
|
+ # @param letype LeType|str : LeType child class or name
|
|
83
|
+ # @param leclass LeClass|str : LeClass child class or name
|
|
84
|
+ # @param filters list : list of filters (see @ref leobject_filters)
|
|
85
|
+ @classmethod
|
|
86
|
+ def update(cls, letype, leclass, filters, datas):
|
|
87
|
+ filters,relationnal_filters = leobject.leobject._LeObject._prepare_filters(filters, cls, cls._leclass)
|
|
88
|
+ letype, leclass = cls._prepare_targets(letype, leclass)
|
|
89
|
+ if letype is None:
|
|
90
|
+ raise ValueError("Argument letype cannot be None")
|
|
91
|
+ letype.check_datas_or_raise(datas, False)
|
|
92
|
+ return cls._datasource(letype, leclass, filters, relationnal_filters, datas)
|
99
|
93
|
|
100
|
94
|
## @brief make a search to retrieve a collection of LeObject
|
101
|
95
|
# @param query_filters list : list of string of query filters (or tuple (FIELD, OPERATOR, VALUE) ) see @ref leobject_filters
|
|
@@ -105,7 +99,7 @@ class _LeObject(object):
|
105
|
99
|
# @return responses ({string:*}): a list of dict with field:value
|
106
|
100
|
def get(self, query_filters, field_list = None, typename = None, classname = None):
|
107
|
101
|
|
108
|
|
- letype,leclass = self._prepare_target(typename, classname)
|
|
102
|
+ letype,leclass = self._prepare_targets(typename, classname)
|
109
|
103
|
|
110
|
104
|
#Fetching LeType
|
111
|
105
|
if typename is None:
|