Browse Source

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

Roland Haroutiounian 9 years ago
parent
commit
50af1b16a8
1 changed files with 28 additions and 0 deletions
  1. 28
    0
      leobject/datasources/ledatasourcesql.py

+ 28
- 0
leobject/datasources/ledatasourcesql.py View File

@@ -13,12 +13,37 @@ class LeDataSourceSQL(DummyDatasource):
13 13
         super(LeDataSourceSQL, self).__init__()
14 14
         self.db = Database(self.module, self.conn_args, self.conn_kargs)
15 15
 
16
+    ## @brief update an existing object's data
17
+    # @param lodel_id int : lodel_id of the object to update
18
+    # @param checked_data dict
19
+    # @param filters
20
+    # @param relational_filters
21
+    def update (self, lodel_id, checked_data, filters, relational_filters):
22
+        pass
23
+
24
+    ## @brief create a new object in the datasource
25
+    # @param letype LeType
26
+    # @param leclass LeClass
27
+    # @param data dict : dictionnary of field:value pairs to save
28
+    # @return lodel_id int : lodel_id of the created object
29
+    def insert(self, letype, leclass, **data):
30
+        pass
31
+
32
+    ## @brief delete an existing object
33
+    # @param lodel_id int : lodel_id of the object to delete
34
+    # @param filters list : list of typles formatted as (FIELD, OPERATOR, VALUE)
35
+    # @param relational_filters list
36
+    # @return bool : True on success
37
+    def delete(self, lodel_id, filters, relational_filters):
38
+        pass
39
+
16 40
     ## @brief search for a collection of objects
17 41
     # @param emclass
18 42
     # @param emtype
19 43
     # @param filters list : list of tuples formatted as (FIELD, OPERATOR, VALUE)
20 44
     # @param relational_filters
21 45
     def get(self, emclass, emtype, field_list, filters, relational_filters):
46
+
22 47
         tablename =  emclass.name
23 48
         where_filters = self._prepare_filters(filters)
24 49
         rel_filters = self._prepare_filters(relational_filters)
@@ -26,6 +51,9 @@ class LeDataSourceSQL(DummyDatasource):
26 51
         self.db.execute(query)
27 52
         return all_to_dicts(self.db)
28 53
 
54
+    # @brief prepares the filters to be used by the mosql library's functions
55
+    # @params filters : (FIELD, OPERATOR, VALUE) tuples
56
+    # @return dict : Dictionnary with (FIELD, OPERATOR):VALUE style elements
29 57
     def _prepare_filters(self, filters):
30 58
         prepared_filters = {}
31 59
         for filter in filters:

Loading…
Cancel
Save