1
0
Fork 0
mirror of https://github.com/yweber/lodel2.git synced 2026-08-08 13:28:37 +02:00

[#61] Added the empty functions : update, insert, delete to the LeDataSourceSQL class

This commit is contained in:
Roland Haroutiounian 2015-10-22 14:17:05 +02:00
commit 50af1b16a8

View file

@ -13,12 +13,37 @@ class LeDataSourceSQL(DummyDatasource):
super(LeDataSourceSQL, self).__init__()
self.db = Database(self.module, self.conn_args, self.conn_kargs)
## @brief update an existing object's data
# @param lodel_id int : lodel_id of the object to update
# @param checked_data dict
# @param filters
# @param relational_filters
def update (self, lodel_id, checked_data, filters, relational_filters):
pass
## @brief create a new object in the datasource
# @param letype LeType
# @param leclass LeClass
# @param data dict : dictionnary of field:value pairs to save
# @return lodel_id int : lodel_id of the created object
def insert(self, letype, leclass, **data):
pass
## @brief delete an existing object
# @param lodel_id int : lodel_id of the object to delete
# @param filters list : list of typles formatted as (FIELD, OPERATOR, VALUE)
# @param relational_filters list
# @return bool : True on success
def delete(self, lodel_id, filters, relational_filters):
pass
## @brief search for a collection of objects
# @param emclass
# @param emtype
# @param filters list : list of tuples formatted as (FIELD, OPERATOR, VALUE)
# @param relational_filters
def get(self, emclass, emtype, field_list, filters, relational_filters):
tablename = emclass.name
where_filters = self._prepare_filters(filters)
rel_filters = self._prepare_filters(relational_filters)
@ -26,6 +51,9 @@ class LeDataSourceSQL(DummyDatasource):
self.db.execute(query)
return all_to_dicts(self.db)
# @brief prepares the filters to be used by the mosql library's functions
# @params filters : (FIELD, OPERATOR, VALUE) tuples
# @return dict : Dictionnary with (FIELD, OPERATOR):VALUE style elements
def _prepare_filters(self, filters):
prepared_filters = {}
for filter in filters: