Browse Source

[#61] Moved ledatasource into dummy

Roland Haroutiounian 9 years ago
parent
commit
2fedc186da

+ 25
- 21
leobject/datasources/dummy.py View File

@@ -7,39 +7,43 @@
7 7
 
8 8
 class DummyDatasource(object):
9 9
 
10
-    def __init__(self, options=None):
11
-        self.options = options
10
+    def __init__(self, module=None, *conn_args, **conn_kargs):
11
+        self.module = module
12
+        self.conn_args = conn_args
13
+        self.conn_kargs = conn_kargs
14
+
15
+    ## @brief update an existing LeObject
16
+    # @param lodel_id (int) : list of lodel_id
17
+    # @param checked_data dict
18
+    # @param datasource_filters (string)
19
+    def update(self, lodel_id, checked_data, datasource_filters):
20
+        print ("DummyDatasource.update: ", lodel_id, checked_data, datasource_filters)
21
+        return True
12 22
 
13 23
     ## @brief create a new LeObject
24
+    # @param typename string
25
+    # @param classname string
14 26
     # @param data dict: a dictionnary of field:value to save
15 27
     # @return lodel_id int: new lodel_id of the newly created LeObject
16
-    def insert(self, data):
17
-        print("DummyDatasource.insert: ", data)
28
+    def insert(self, typename, classname, **datas):
29
+        print("DummyDatasource.insert: ", typename, classname, datas)
18 30
         return 42
19 31
 
20
-    ## @brief update an existing LeObject
21
-    # @param lodel_id int | (int): lodel_id of the object(s) where to apply changes
22
-    # @param data dict: dictionnary of field:value to save
23
-    # @param update_filters string | (string): list of string of update filters
24
-    # @return okay bool: True on success, it will raise on failure
25
-    def update(self, lodel_id, data, update_filters=None):
26
-        print("DummyDatasource.update: ", lodel_id, data, update_filters)
27
-
28
-        return True
29
-
30 32
     ## @brief delete an existing LeObject
31 33
     # @param lodel_id int | (int): lodel_id of the object(s) to delete
32 34
     # @param delete_filters string | (string): list of string of delete filters
33 35
     # @return okay bool: True on success, it will raise on failure
34 36
     def delete(self, lodel_id, delete_filters=None):
35 37
         print("DummyDatasource.delete: ", lodel_id, delete_filters)
36
-
37 38
         return True
38 39
 
39
-    ## @brief make a search to retrieve a collection of LeObject
40
-    # @param query_filters string | (string): list of string of query filters
40
+    ## @brief search for a collection of objects
41
+    # @param emclass LeClass : LeClass instance
42
+    # @param emtype LeType : LeType instance
43
+    # @param field_list list : list of fields to get from the datasource
44
+    # @param filters list : list of tuples formatted as (FIELD, OPERATOR, VALUE)
45
+    # @param relational_filters
41 46
     # @return responses ({string:*}): a list of dict with field:value
42
-    def get(self, query_filters):
43
-        print("DummyDatasource.get: ", query_filters)
44
-
45
-        return False
47
+    def get(self, emclass, emtype, field_list, filters, relational_filters):
48
+        print("DummyDatasource.get: ", emclass, emtype, field_list, filters, relational_filters)
49
+        return []

+ 0
- 39
leobject/datasources/ledatasource.py View File

@@ -1,39 +0,0 @@
1
-#-*- coding: utf-8 -*-
2
-
3
-## Generic DataSource for LeObject
4
-
5
-class LeDataSource(object):
6
-
7
-    def __init__(self, module=None, *conn_args, **conn_kargs):
8
-        self.module = module
9
-        self.conn_args = conn_args
10
-        self.conn_kargs = conn_kargs
11
-
12
-    ## @brief update an existing LeObject
13
-    # @param lodel_id (int) : list of lodel_id
14
-    # @param checked_data dict
15
-    # @param datasource_filters (string)
16
-    def update(self, lodel_id, checked_data, datasource_filters):
17
-        return True
18
-
19
-    ## @brief insert
20
-    # @param typename string
21
-    # @param classname string
22
-    # @param **datas dict
23
-    def insert(self, typename, classname, **datas):
24
-        return True
25
-
26
-    ## @brief delete
27
-    # @param lodel_id (int) : list of lode_id(s) to delete
28
-    def delete(self, lodel_id):
29
-        return True
30
-    
31
-    ## @brief search for a collection of objects
32
-    # @param emclass LeClass : LeClass instance
33
-    # @param emtype LeType : LeType instance
34
-    # @param field_list list : list of fields to get from the datasource
35
-    # @param filters list : list of tuples formatted as (FIELD, OPERATOR, VALUE)
36
-    # @param relational_filters
37
-    def get(self, emclass, emtype, field_list, filters, relational_filters):
38
-        return {}
39
-

+ 2
- 2
leobject/datasources/ledatasourcesql.py View File

@@ -1,13 +1,13 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
-from ledatasource import LeDataSource
3
+from leobject.datasources.dummy import DummyDatasource
4 4
 from mosql.db import Database, all_to_dicts
5 5
 from mosql.query import select
6 6
 
7 7
 from Lodel.utils.mosql import *
8 8
 
9 9
 ## SQL DataSource for LeObject
10
-class LeDataSourceSQL(LeDataSource):
10
+class LeDataSourceSQL(DummyDatasource):
11 11
 
12 12
     def __init__(self, module=None, *conn_args, **conn_kargs):
13 13
         super(LeDataSourceSQL, self).__init__()

Loading…
Cancel
Save