Browse Source

Forgotten files

Yann Weber 8 years ago
parent
commit
ca3fa4cc27

+ 27
- 0
lodel/exceptions.py View File

@@ -0,0 +1,27 @@
1
+#-*- coding: utf-8 -*-
2
+
3
+class LodelException(Exception):
4
+    pass
5
+
6
+
7
+class LodelExceptions(LodelException):
8
+    ##@brief Instanciate a new exceptions handling multiple exceptions
9
+    # @param msg str : Exception message
10
+    # @param exceptions dict : A list of data check Exception with concerned field (or stuff) as key
11
+    def __init__(self, msg = "Unknow error", exceptions = None):
12
+        self._msg = msg
13
+        self._exceptions = dict() if exceptions is None else exceptions
14
+
15
+    def __repr__(self):
16
+        return self.__str__()
17
+
18
+    def __str__(self):
19
+        msg = self._msg
20
+        for_iter = self._exceptions.items() if isinstance(self._exceptions, dict) else enumerate(self.__exceptions)
21
+        for obj, expt in for_iter:
22
+            msg += "\n\t{expt_obj} : ({expt_name}) {expt_msg}; ".format(
23
+                    expt_obj = obj,
24
+                    expt_name=expt.__class__.__name__,
25
+                    expt_msg=str(expt)
26
+            )
27
+        return msg

+ 0
- 0
plugins/__init__.py View File


+ 53
- 0
plugins/dummy_datasource/datasource.py View File

@@ -0,0 +1,53 @@
1
+#-*- coding:utf-8 -*-
2
+
3
+class DummyDatasource(object):
4
+    
5
+    def __init__(self, *conn_args, **conn_kwargs):
6
+        self.conn_args = conn_args
7
+        self.conn_kwargs = conn_kwargs
8
+
9
+    ## @brief returns a selection of documents from the datasource
10
+    # @param target_cls Emclass
11
+    # @param field_list list
12
+    # @param filters list : List of filters
13
+    # @param rel_filters list : List of relational filters
14
+    # @param order list : List of column to order. ex: order = [('title', 'ASC'),]
15
+    # @param group list : List of tupple representing the column to group together. ex: group = [('title', 'ASC'),]
16
+    # @param limit int : Number of records to be returned
17
+    # @param offset int: used with limit to choose the start record
18
+    # @param instanciate bool : If true, the records are returned as instances, else they are returned as dict
19
+    # @return list
20
+    def select(self, target_cls, field_list, filters, rel_filters=None, order=None, group=None, limit=None, offset=0,
21
+               instanciate=True):
22
+        pass
23
+
24
+    ##@brief Deletes records according to given filters
25
+    #@param target Emclass : class of the record to delete
26
+    #@param filters list : List of filters
27
+    #@param relational_filters list : List of relational filters
28
+    #@return int : number of deleted records
29
+    def delete(self, target, filters, relational_filters):
30
+        pass
31
+
32
+    ## @brief updates records according to given filters
33
+    #@param target Emclass : class of the object to insert
34
+    #@param filters list : List of filters
35
+    #@param rel_filters list : List of relational filters
36
+    #@param upd_datas dict : datas to update (new values)
37
+    #@return int : Number of updated records
38
+    def update(self, target, filters, relational_filters, upd_datas):
39
+        pass
40
+
41
+    ## @brief Inserts a record in a given collection
42
+    # @param target Emclass : class of the object to insert
43
+    # @param new_datas dict : datas to insert
44
+    # @return the inserted uid
45
+    def insert(self, target, new_datas):
46
+        pass
47
+
48
+    ## @brief Inserts a list of records in a given collection
49
+    # @param target Emclass : class of the objects inserted
50
+    # @param datas_list list : list of dict
51
+    # @return list : list of the inserted records' ids
52
+    def insert_multi(self, target, datas_list):
53
+        pass

+ 13
- 0
plugins/dummy_datasource/migration_handler.py View File

@@ -0,0 +1,13 @@
1
+#-*- coding: utf-8 -*-
2
+
3
+##@brief Abtract class for migration handlers
4
+class DummyMigrationHandler(object):
5
+    def __init__(self, *args, **kwargs):
6
+        pass
7
+    
8
+    def register_change(self, model, uid, initial_state, new_state):
9
+        pass
10
+
11
+    def register_model_state(self, em, state_hash):
12
+        pass
13
+

Loading…
Cancel
Save