|
@@ -19,15 +19,19 @@ from lodel.leapi.datahandlers.base_classes import DataField
|
19
|
19
|
for module in modules:
|
20
|
20
|
imports += "import %s\n" % module
|
21
|
21
|
|
|
22
|
+ class_list = [ LeObject.name2objname(cls.uid) for cls in get_classes(model) ]
|
|
23
|
+
|
22
|
24
|
# formating all components of output
|
23
|
25
|
res_code = """#-*- coding: utf-8 -*-
|
24
|
26
|
{imports}
|
25
|
27
|
{classes}
|
26
|
28
|
{bootstrap_instr}
|
|
29
|
+dynclasses = {class_list}
|
27
|
30
|
""".format(
|
28
|
31
|
imports = imports,
|
29
|
32
|
classes = cls_code,
|
30
|
33
|
bootstrap_instr = bootstrap_instr,
|
|
34
|
+ class_list = '[' + (', '.join([cls for cls in class_list]))+']',
|
31
|
35
|
)
|
32
|
36
|
return res_code
|
33
|
37
|
|
|
@@ -103,6 +107,7 @@ def generate_classes(model):
|
103
|
107
|
parents.append(LeObject.name2objname(parent.uid))
|
104
|
108
|
else:
|
105
|
109
|
parents.append('LeObject')
|
|
110
|
+ datasource_name = em_class.datasource
|
106
|
111
|
|
107
|
112
|
# Dynamic code generation for LeObject childs classes
|
108
|
113
|
em_cls_code = """
|
|
@@ -110,12 +115,14 @@ class {clsname}({parents}):
|
110
|
115
|
_abstract = {abstract}
|
111
|
116
|
_fields = None
|
112
|
117
|
_uid = {uid_list}
|
|
118
|
+ _datasource = {datasource_name}
|
113
|
119
|
|
114
|
120
|
""".format(
|
115
|
121
|
clsname = LeObject.name2objname(em_class.uid),
|
116
|
122
|
parents = ', '.join(parents),
|
117
|
123
|
abstract = 'True' if em_class.abstract else 'False',
|
118
|
124
|
uid_list = repr(uid),
|
|
125
|
+ datasource_name = repr(datasource_name),
|
119
|
126
|
)
|
120
|
127
|
res += em_cls_code
|
121
|
128
|
# Dyncode bootstrap instructions
|