Browse Source

Documentation on the lodel.plugins.dummy_datasource plugin

Roland Haroutiounian 7 years ago
parent
commit
b5b694c8c2

+ 9
- 0
lodel/plugins/dummy_datasource/__init__.py View File

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
 from lodel.context import LodelContext
4
 from lodel.context import LodelContext
2
 LodelContext.expose_modules(globals(), {
5
 LodelContext.expose_modules(globals(), {
3
     'lodel.validator.validator': ['Validator']})
6
     'lodel.validator.validator': ['Validator']})
4
 from .datasource import DummyDatasource as Datasource
7
 from .datasource import DummyDatasource as Datasource
5
 
8
 
9
+## @brief plugin's category
6
 __plugin_type__ = 'datasource'
10
 __plugin_type__ = 'datasource'
11
+## @brief plugin's name (matching the package's name)
7
 __plugin_name__ = "dummy_datasource"
12
 __plugin_name__ = "dummy_datasource"
13
+## @brief plugin's version
8
 __version__ = '0.0.1'
14
 __version__ = '0.0.1'
15
+## @brief plugin's main entry module
9
 __loader__ = 'main.py'
16
 __loader__ = 'main.py'
17
+## @brief plugin's dependances
10
 __plugin_deps__ = []
18
 __plugin_deps__ = []
11
 
19
 
20
+## @brief Plugin's configuration options and their corresponding validators
12
 CONFSPEC = {
21
 CONFSPEC = {
13
     'lodel2.datasource.dummy_datasource.*' : {
22
     'lodel2.datasource.dummy_datasource.*' : {
14
         'dummy': (  None,
23
         'dummy': (  None,

+ 30
- 25
lodel/plugins/dummy_datasource/datasource.py View File

1
 #-*- coding:utf-8 -*-
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
 from lodel.context import LodelContext
5
 from lodel.context import LodelContext
4
 LodelContext.expose_modules(globals(), {
6
 LodelContext.expose_modules(globals(), {
5
     'lodel.plugin.datasource_plugin': ['AbstractDatasource']})
7
     'lodel.plugin.datasource_plugin': ['AbstractDatasource']})
6
 
8
 
9
+## @brief Datasource class, inherited from @ref lodel.plugin.datasource.AbstractDatasource
7
 class DummyDatasource(AbstractDatasource):
10
 class DummyDatasource(AbstractDatasource):
8
     
11
     
12
+    ##
13
+    # @param conn_args list
14
+    # @param conn_kwargs dict
9
     def __init__(self, *conn_args, **conn_kwargs):
15
     def __init__(self, *conn_args, **conn_kwargs):
10
         self.conn_args = conn_args
16
         self.conn_args = conn_args
11
         self.conn_kwargs = conn_kwargs
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
     def new_numeric_id(self, emcomp):
22
     def new_numeric_id(self, emcomp):
18
         pass
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
     def select(self, target, field_list, filters, relational_filters=None, order=None, group=None, limit=None, offset=0,
36
     def select(self, target, field_list, filters, relational_filters=None, order=None, group=None, limit=None, offset=0,
32
                instanciate=True):
37
                instanciate=True):
33
         pass
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
     def delete(self, target, filters, relational_filters):
45
     def delete(self, target, filters, relational_filters):
41
         return 0
46
         return 0
42
 
47
 
43
     ## @brief updates records according to given filters
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
     def update(self, target, filters, relational_filters, upd_datas):
54
     def update(self, target, filters, relational_filters, upd_datas):
50
         return 0
55
         return 0
51
 
56
 

+ 4
- 0
lodel/plugins/dummy_datasource/main.py View File

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

+ 23
- 6
lodel/plugins/dummy_datasource/migration_handler.py View File

1
 #-*- coding: utf-8 -*-
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
 class DummyMigrationHandler(object):
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
     def __init__(self, *args, **kwargs):
16
     def __init__(self, *args, **kwargs):
8
         pass
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
     def init_db(self, emclass_list):
21
     def init_db(self, emclass_list):
13
         pass
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
     def register_change(self, model, uid, initial_state, new_state):
30
     def register_change(self, model, uid, initial_state, new_state):
17
         pass
31
         pass
18
 
32
 
19
-    ##@todo redefine
33
+    ##
34
+    # @param em EditorialModel
35
+    # @param state_hash str
36
+    # @todo redefine
20
     def register_model_state(self, em, state_hash):
37
     def register_model_state(self, em, state_hash):
21
         pass
38
         pass
22
     
39
     

Loading…
Cancel
Save