|
@@ -1,10 +1,12 @@
|
1
|
1
|
#-*- coding: utf-8 -*-
|
2
|
2
|
|
3
|
|
-from leobject import LeObject
|
|
3
|
+from .leobject import LeObject
|
|
4
|
+
|
4
|
5
|
|
5
|
6
|
class LeQueryError(Exception):
|
6
|
7
|
pass
|
7
|
8
|
|
|
9
|
+
|
8
|
10
|
## @brief Handle CRUD operations on datasource
|
9
|
11
|
class LeQuery(object):
|
10
|
12
|
|
|
@@ -15,27 +17,39 @@ class LeQuery(object):
|
15
|
17
|
raise TypeError("target_class have to be a child class of LeObject")
|
16
|
18
|
self._target_class = target_class
|
17
|
19
|
|
|
20
|
+
|
18
|
21
|
## @brief Handles insert queries
|
19
|
22
|
class LeInsertQuery(LeQuery):
|
20
|
23
|
|
|
24
|
+ # Name of the corresponding action
|
|
25
|
+ action = 'insert'
|
|
26
|
+
|
21
|
27
|
def __init__(self, target_class):
|
22
|
28
|
super().__init__(target_class)
|
23
|
29
|
if target_class.is_abstract():
|
24
|
30
|
raise LeQueryError("Target EmClass cannot be abstract for an InsertQuery")
|
25
|
31
|
|
|
32
|
+
|
26
|
33
|
## @brief Handles Le*Query with a query_filter argument
|
27
|
34
|
# @see LeGetQuery, LeUpdateQuery, LeDeleteQuery
|
28
|
35
|
class LeFilteredQuery(LeQuery):
|
29
|
|
- pass
|
|
36
|
+ # Name of the corresponding action
|
|
37
|
+ action = 'update'
|
|
38
|
+
|
30
|
39
|
|
31
|
40
|
## @brief Handles Get queries
|
32
|
41
|
class LeGetQuery(LeFilteredQuery):
|
33
|
|
- pass
|
|
42
|
+ # Name of the corresponding action
|
|
43
|
+ action = 'get'
|
|
44
|
+
|
34
|
45
|
|
35
|
46
|
## @brief Handles Update queries
|
36
|
47
|
class LeUpdateQuery(LeFilteredQuery):
|
37
|
|
- pass
|
|
48
|
+ # Name of the corresponding action
|
|
49
|
+ action = 'update'
|
38
|
50
|
|
39
|
|
-## @biref Handles Delete queries
|
40
|
|
-class LeInsertQuery(LeFilteredQuery):
|
41
|
|
- pass
|
|
51
|
+
|
|
52
|
+## @brief Handles Delete queries
|
|
53
|
+class LeDeleteQuery(LeFilteredQuery):
|
|
54
|
+ # Name of the corresponding action
|
|
55
|
+ action = 'delete'
|