Browse Source

Adding datasourc boostrapîng instructions in leaftory generated dyncode

+ better log message for datasource bootstrap
Yann Weber 9 years ago
parent
commit
b683d68d83
2 changed files with 12 additions and 3 deletions
  1. 7
    1
      lodel/leapi/lefactory.py
  2. 5
    2
      lodel/leapi/leobject.py

+ 7
- 1
lodel/leapi/lefactory.py View File

@@ -125,11 +125,17 @@ class {clsname}({parents}):
125 125
     datasource_name = repr(datasource_name),
126 126
 )
127 127
         res += em_cls_code
128
-        # Dyncode bootstrap instructions
128
+        # Dyncode fields bootstrap instructions
129 129
         bootstrap += """{classname}._set__fields({fields})
130 130
 """.format(
131 131
     classname = LeObject.name2objname(em_class.uid),
132 132
     fields = '{' + (', '.join(['\n\t%s: %s' % (repr(emfield.uid),data_handler_constructor(emfield)) for emfield in em_class.fields()])) + '}',
133 133
 )
134
+    bootstrap += "\n"
135
+    for em_class in get_classes(model):
136
+        # Dyncode datasource bootstrap instructions
137
+        bootstrap += """{classname}._init_datasource()
138
+""".format(
139
+            classname = LeObject.name2objname(em_class.uid))
134 140
     return res, set(imports), bootstrap
135 141
     

+ 5
- 2
lodel/leapi/leobject.py View File

@@ -192,11 +192,12 @@ class LeObject(object):
192 192
     @classmethod
193 193
     def _init_datasource(cls):
194 194
         expt_msg = "In LeAPI class '%s' " % cls.__name__
195
+        datasource_orig_name = cls._datasource
195 196
         if cls._datasource not in Settings.datasources._fields:
196 197
             expt_msg += "Unknow or unconfigured datasource %s"
197 198
             expt_msg %= (cls._datasource, cls.__name__)
198 199
             raise SettingsError(expt_msg)
199
-
200
+        
200 201
         ds_identifier = getattr(Settings.datasources, cls._datasource)
201 202
         try:
202 203
             ds_identifier = getattr(ds_identifier, 'identifier')
@@ -228,7 +229,9 @@ class LeObject(object):
228 229
             expt_msg += "The datasource plugin %s seems to be invalid. Error raised when trying to import Datasource"
229 230
             expt_msg %= ds_identifier
230 231
             raise SettingsError(expt_msg)
231
-        logger.debug("Datasource initialized for LeObject %s" % cls.__name__)
232
+        log_msg = "Datasource %s initialized for LeObject %s"
233
+        log_msg %= (datasource_orig_name, cls.__name__)
234
+        logger.debug(log_msg)
232 235
 
233 236
     ##@brief Read only access to all datas
234 237
     # @note for fancy data accessor use @ref LeObject.g attribute @ref LeObjectValues instance

Loading…
Cancel
Save