|
@@ -1,5 +1,6 @@
|
1
|
1
|
from .plugins import Plugin
|
2
|
2
|
from .exceptions import *
|
|
3
|
+from lodel.exceptions import *
|
3
|
4
|
from lodel.settings.validator import SettingValidator
|
4
|
5
|
|
5
|
6
|
|
|
@@ -162,6 +163,71 @@ but %s is a %s" % (ds_name, pinstance.__class__.__name__))
|
162
|
163
|
def get_migration_handler(cls, ds_plugin_name):
|
163
|
164
|
return cls.get(ds_plugin_name).migration_handler_cls()
|
164
|
165
|
|
|
166
|
+class AbstractDatasource(object):
|
|
167
|
+
|
|
168
|
+ ##@brief Trigger LodelFatalError when abtract method called
|
|
169
|
+ @staticmethod
|
|
170
|
+ def _abs_err():
|
|
171
|
+ raise LodelFatalError("This method is abstract and HAVE TO be \
|
|
172
|
+reimplemented by plugin datasource child class")
|
|
173
|
+
|
|
174
|
+ ##@brief The constructor
|
|
175
|
+ def __init__(self, *conn_args, **conn_kwargs):
|
|
176
|
+ self._abs_err()
|
|
177
|
+
|
|
178
|
+ ##@brief Provide a new uniq numeric ID
|
|
179
|
+ #@param emcomp LeObject subclass (not instance) : To know on wich things we
|
|
180
|
+ #have to be uniq
|
|
181
|
+ #@return an integer
|
|
182
|
+ def new_numeric_id(self, emcomp):
|
|
183
|
+ self._abs_err()
|
|
184
|
+
|
|
185
|
+ ##@brief returns a selection of documents from the datasource
|
|
186
|
+ #@param target_cls Emclass
|
|
187
|
+ #@param field_list list
|
|
188
|
+ #@param filters list : List of filters
|
|
189
|
+ #@param rel_filters list : List of relational filters
|
|
190
|
+ #@param order list : List of column to order. ex: order = [('title', 'ASC'),]
|
|
191
|
+ #@param group list : List of tupple representing the column to group together. ex: group = [('title', 'ASC'),]
|
|
192
|
+ #@param limit int : Number of records to be returned
|
|
193
|
+ #@param offset int: used with limit to choose the start record
|
|
194
|
+ #@param instanciate bool : If true, the records are returned as instances, else they are returned as dict
|
|
195
|
+ #@return list
|
|
196
|
+ def select(self, target, field_list, filters, rel_filters=None, order=None, group=None, limit=None, offset=0,
|
|
197
|
+ instanciate=True):
|
|
198
|
+ self._abs_err()
|
|
199
|
+
|
|
200
|
+ ##@brief Deletes records according to given filters
|
|
201
|
+ #@param target Emclass : class of the record to delete
|
|
202
|
+ #@param filters list : List of filters
|
|
203
|
+ #@param relational_filters list : List of relational filters
|
|
204
|
+ #@return int : number of deleted records
|
|
205
|
+ def delete(self, target, filters, relational_filters):
|
|
206
|
+ self._abs_err()
|
|
207
|
+
|
|
208
|
+ ## @brief updates records according to given filters
|
|
209
|
+ #@param target Emclass : class of the object to insert
|
|
210
|
+ #@param filters list : List of filters
|
|
211
|
+ #@param relational_filters list : List of relational filters
|
|
212
|
+ #@param upd_datas dict : datas to update (new values)
|
|
213
|
+ #@return int : Number of updated records
|
|
214
|
+ def update(self, target, filters, relational_filters, upd_datas):
|
|
215
|
+ self._abs_err()
|
|
216
|
+
|
|
217
|
+ ## @brief Inserts a record in a given collection
|
|
218
|
+ # @param target Emclass : class of the object to insert
|
|
219
|
+ # @param new_datas dict : datas to insert
|
|
220
|
+ # @return the inserted uid
|
|
221
|
+ def insert(self, target, new_datas):
|
|
222
|
+ self._abs_err()
|
|
223
|
+
|
|
224
|
+ ## @brief Inserts a list of records in a given collection
|
|
225
|
+ # @param target Emclass : class of the objects inserted
|
|
226
|
+ # @param datas_list list : list of dict
|
|
227
|
+ # @return list : list of the inserted records' ids
|
|
228
|
+ def insert_multi(self, target, datas_list):
|
|
229
|
+ self._abs_err()
|
|
230
|
+
|
165
|
231
|
##@page lodel2_datasources Lodel2 datasources
|
166
|
232
|
#
|
167
|
233
|
#@par lodel2_datasources_intro Intro
|