|
@@ -1,5 +1,6 @@
|
1
|
1
|
#-*- coding: utf-8 -*-
|
2
|
2
|
|
|
3
|
+import os, os.path
|
3
|
4
|
import functools
|
4
|
5
|
from lodel.editorial_model.components import *
|
5
|
6
|
from lodel.leapi.leobject import LeObject
|
|
@@ -28,29 +29,33 @@ from lodel.plugin.hooks import LodelHook
|
28
|
29
|
{imports}
|
29
|
30
|
{classes}
|
30
|
31
|
{bootstrap_instr}
|
|
32
|
+#List of dynamically generated classes
|
31
|
33
|
dynclasses = {class_list}
|
32
|
|
-{init_hook}
|
|
34
|
+#Dict of dynamically generated classes indexed by name
|
|
35
|
+dynclasses_dict = {class_dict}
|
|
36
|
+{common_code}
|
33
|
37
|
""".format(
|
34
|
38
|
imports = imports,
|
35
|
39
|
classes = cls_code,
|
36
|
40
|
bootstrap_instr = bootstrap_instr,
|
37
|
41
|
class_list = '[' + (', '.join([cls for cls in class_list]))+']',
|
38
|
|
- init_hook = datasource_init_hook(),
|
|
42
|
+ class_dict = '{' + (', '.join([ "'%s': %s" % (cls, cls)
|
|
43
|
+ for cls in class_list]))+'}',
|
|
44
|
+ common_code = common_code(),
|
39
|
45
|
)
|
40
|
46
|
return res_code
|
41
|
47
|
|
42
|
|
-##@brief Produce the source code of the LodelHook that initialize datasources
|
43
|
|
-#in dyncode
|
44
|
|
-#@return str
|
45
|
|
-def datasource_init_hook():
|
46
|
|
- return """
|
47
|
|
-@LodelHook("lodel2_plugins_loaded")
|
48
|
|
-def lodel2_dyncode_datasources_init(self, caller, payload):
|
49
|
|
- for cls in dynclasses:
|
50
|
|
- cls._init_datasources()
|
51
|
|
- from lodel.plugin.hooks import LodelHook
|
52
|
|
- LodelHook.call_hook("lodel2_dyncode_loaded", __name__, dynclasses)
|
53
|
|
-"""
|
|
48
|
+##@brief Return the content of lodel.leapi.lefactory_common
|
|
49
|
+def common_code():
|
|
50
|
+ res = ""
|
|
51
|
+ fname = os.path.dirname(__file__)
|
|
52
|
+ fname = os.path.join(fname, 'lefactory_common.py')
|
|
53
|
+ with open(fname, 'r') as cfp:
|
|
54
|
+ for line in cfp:
|
|
55
|
+ if not line.startswith('#-'):
|
|
56
|
+ res += line
|
|
57
|
+ return res
|
|
58
|
+
|
54
|
59
|
|
55
|
60
|
##@brief return A list of EmClass sorted by dependencies
|
56
|
61
|
#
|