瀏覽代碼

Documentation on the lodel.plugins.dummy_datasource plugin

Roland Haroutiounian 7 年之前
父節點
當前提交
b5b694c8c2

+ 9
- 0
lodel/plugins/dummy_datasource/__init__.py 查看文件

@@ -1,14 +1,23 @@
1
+## @package lodel.plugins.dummy_datasource Example of a datasource type plugin
2
+
3
+# Here we use the Lodel Context Manager to expose the modules which are specific to the application
1 4
 from lodel.context import LodelContext
2 5
 LodelContext.expose_modules(globals(), {
3 6
     'lodel.validator.validator': ['Validator']})
4 7
 from .datasource import DummyDatasource as Datasource
5 8
 
9
+## @brief plugin's category
6 10
 __plugin_type__ = 'datasource'
11
+## @brief plugin's name (matching the package's name)
7 12
 __plugin_name__ = "dummy_datasource"
13
+## @brief plugin's version
8 14
 __version__ = '0.0.1'
15
+## @brief plugin's main entry module
9 16
 __loader__ = 'main.py'
17
+## @brief plugin's dependances
10 18
 __plugin_deps__ = []
11 19
 
20
+## @brief Plugin's configuration options and their corresponding validators
12 21
 CONFSPEC = {
13 22
     'lodel2.datasource.dummy_datasource.*' : {
14 23
         'dummy': (  None,

+ 30
- 25
lodel/plugins/dummy_datasource/datasource.py 查看文件

@@ -1,51 +1,56 @@
1 1
 #-*- coding:utf-8 -*-
2 2
 
3
+## @package lodel.plugins.dummy_datasource.datasource This module contains the main class of the datasource, implementing the basic operations one can perform.
4
+
3 5
 from lodel.context import LodelContext
4 6
 LodelContext.expose_modules(globals(), {
5 7
     'lodel.plugin.datasource_plugin': ['AbstractDatasource']})
6 8
 
9
+## @brief Datasource class, inherited from @ref lodel.plugin.datasource.AbstractDatasource
7 10
 class DummyDatasource(AbstractDatasource):
8 11
     
12
+    ##
13
+    # @param conn_args list
14
+    # @param conn_kwargs dict
9 15
     def __init__(self, *conn_args, **conn_kwargs):
10 16
         self.conn_args = conn_args
11 17
         self.conn_kwargs = conn_kwargs
12 18
     
13
-    ##@brief Provide a new uniq numeric ID
14
-    #@param emcomp LeObject subclass (not instance) : To know on wich things we
15
-    #have to be uniq
16
-    #@return an integer
19
+    ## @brief Provides a new unique numeric ID
20
+    # @param emcomp LeObject subclass (not instance) : The class against whom we have to be unique
21
+    # @return an integer
17 22
     def new_numeric_id(self, emcomp):
18 23
         pass
19 24
 
20
-    ##@brief returns a selection of documents from the datasource
21
-    #@param target Emclass
22
-    #@param field_list list
23
-    #@param filters list : List of filters
24
-    #@param relational_filters list : List of relational filters
25
-    #@param order list : List of column to order. ex: order = [('title', 'ASC'),]
26
-    #@param group list : List of tupple representing the column to group together. ex: group = [('title', 'ASC'),]
27
-    #@param limit int : Number of records to be returned
28
-    #@param offset int: used with limit to choose the start record
29
-    #@param instanciate bool : If true, the records are returned as instances, else they are returned as dict
30
-    #@return list
25
+    ## @brief returns a selection of documents from the datasource
26
+    # @param target Emclass
27
+    # @param field_list list
28
+    # @param filters list : List of filters
29
+    # @param relational_filters list : List of relational filters (default value : None)
30
+    # @param order list : List of column to order. ex: order = [('title', 'ASC'),] (default value : None)
31
+    # @param group list : List of tupple representing the column to group together. ex: group = [('title', 'ASC'),] (default value : None)
32
+    # @param limit int : Number of records to be returned (default value : None)
33
+    # @param offset int: used with limit to choose the start record (default value : 0)
34
+    # @param instanciate bool : If true, the records are returned as instances, else they are returned as dict (default value : True)
35
+    # @return list
31 36
     def select(self, target, field_list, filters, relational_filters=None, order=None, group=None, limit=None, offset=0,
32 37
                instanciate=True):
33 38
         pass
34 39
 
35
-    ##@brief Deletes records according to given filters
36
-    #@param target Emclass : class of the record to delete
37
-    #@param filters list : List of filters
38
-    #@param relational_filters list : List of relational filters
39
-    #@return int : number of deleted records
40
+    ## @brief Deletes records according to given filters
41
+    # @param target Emclass : class of the record to delete
42
+    # @param filters list : List of filters
43
+    # @param relational_filters list : List of relational filters
44
+    # @return int : number of deleted records
40 45
     def delete(self, target, filters, relational_filters):
41 46
         return 0
42 47
 
43 48
     ## @brief updates records according to given filters
44
-    #@param target Emclass : class of the object to insert
45
-    #@param filters list : List of filters
46
-    #@param relational_filters list : List of relational filters
47
-    #@param upd_datas dict : datas to update (new values)
48
-    #@return int : Number of updated records
49
+    # @param target Emclass : class of the object to insert
50
+    # @param filters list : List of filters
51
+    # @param relational_filters list : List of relational filters
52
+    # @param upd_datas dict : datas to update (new values)
53
+    # @return int : Number of updated records
49 54
     def update(self, target, filters, relational_filters, upd_datas):
50 55
         return 0
51 56
 

+ 4
- 0
lodel/plugins/dummy_datasource/main.py 查看文件

@@ -1,10 +1,14 @@
1 1
 #-*- coding:utf-8 -*-
2 2
 
3
+## @package lodel.plugins.dummy_datasource.main The main module of the plugin. 
4
+
3 5
 from lodel.context import LodelContext
4 6
 LodelContext.expose_modules(globals(), {
5 7
     'lodel.plugin': ['LodelHook']})
6 8
 from .datasource import DummyDatasource as Datasource
7 9
 
10
+## @brief returns the migration handler of this plugin. 
11
+# @retunr DummyMigrationHandler
8 12
 def migration_handler_class():
9 13
     from .migration_handler import DummyMigrationHandler as migration_handler
10 14
     return migration_handler

+ 23
- 6
lodel/plugins/dummy_datasource/migration_handler.py 查看文件

@@ -1,22 +1,39 @@
1 1
 #-*- coding: utf-8 -*-
2 2
 
3
-##@brief Abtract class for migration handlers
3
+## @package lodel.plugins.dummy_datasource.migration_handler Migration handler of the datasource plugin. 
4
+#
5
+# The migration handler is here to report the changes made in the editorial model to the data source. 
6
+# 
7
+# For a database, it could be the creation/deletion of tables, the addition/deletion/change of certain columns, etc...
8
+#
9
+# We also have here the datasource initialization process, for the first use of it. The migration handler will then
10
+# use the editorial model to generate the corresponding data storage. 
11
+
12
+## @brief Abtract class for migration handlers
4 13
 class DummyMigrationHandler(object):
5 14
 
6
-    ##@brief Create a new migration handler given DB connection options
15
+    ## @brief Create a new migration handler given DB connection options
7 16
     def __init__(self, *args, **kwargs):
8 17
         pass
9 18
     
10
-    ##@brief DB initialisation
11
-    #@param emclass_list list : list of EmClasses concerned by this MH
19
+    ## @brief DB initialisation
20
+    # @param emclass_list list : list of EmClasses concerned by this MH
12 21
     def init_db(self, emclass_list):
13 22
         pass
14 23
     
15
-    ##@todo redefine
24
+    ## @brief register a change in the editorial model
25
+    # @param model EditorialModel
26
+    # @param uid
27
+    # @param initial_state
28
+    # @param new_state
29
+    # @todo redefine
16 30
     def register_change(self, model, uid, initial_state, new_state):
17 31
         pass
18 32
 
19
-    ##@todo redefine
33
+    ##
34
+    # @param em EditorialModel
35
+    # @param state_hash str
36
+    # @todo redefine
20 37
     def register_model_state(self, em, state_hash):
21 38
         pass
22 39
     

Loading…
取消
儲存