Browse Source

Bugfixes concerning UniqID and select on abtract LeObject child

Yann Weber 8 years ago
parent
commit
8e6e60f0f4
2 changed files with 13 additions and 4 deletions
  1. 7
    1
      lodel/leapi/lefactory.py
  2. 6
    3
      plugins/mongodb_datasource/datasource.py

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

145
 )
145
 )
146
         res += em_cls_code
146
         res += em_cls_code
147
         # Dyncode fields bootstrap instructions
147
         # Dyncode fields bootstrap instructions
148
+        child_classes = model.get_class_childs(em_class.uid)
149
+        if len(child_classes) == 0:
150
+            child_classes = 'tuple()'
151
+        else:
152
+            child_classes = '(%s,)' % (', '.join(
153
+                [ LeObject.name2objname(emcls.uid) for emcls in child_classes]))
148
         bootstrap += """{classname}._set__fields({fields})
154
         bootstrap += """{classname}._set__fields({fields})
149
 {classname}._child_classes = {child_classes}
155
 {classname}._child_classes = {child_classes}
150
 """.format(
156
 """.format(
151
     classname = LeObject.name2objname(em_class.uid),
157
     classname = LeObject.name2objname(em_class.uid),
152
     fields = '{' + (', '.join(['\n\t%s: %s' % (repr(emfield.uid),data_handler_constructor(emfield)) for emfield in em_class.fields()])) + '}',
158
     fields = '{' + (', '.join(['\n\t%s: %s' % (repr(emfield.uid),data_handler_constructor(emfield)) for emfield in em_class.fields()])) + '}',
153
-    child_classes = '(' + (', '.join([ LeObject.name2objname(emcls.uid) for emcls in model.get_class_childs(em_class.uid)]))+ ')',
159
+    child_classes = child_classes,
154
 )
160
 )
155
     bootstrap += "\n"
161
     bootstrap += "\n"
156
     return res, set(imports), bootstrap
162
     return res, set(imports), bootstrap

+ 6
- 3
plugins/mongodb_datasource/datasource.py View File

76
         tuid = target._uid[0] # Multiple UID broken here
76
         tuid = target._uid[0] # Multiple UID broken here
77
         results = self.select(
77
         results = self.select(
78
             target, [tuid], [], order=[(tuid, 'DESC')], limit = 1)
78
             target, [tuid], [], order=[(tuid, 'DESC')], limit = 1)
79
+        if len(results) == 0: 
80
+            return 1
79
         return results[0][tuid]+1
81
         return results[0][tuid]+1
80
 
82
 
81
     ##@brief returns a selection of documents from the datasource
83
     ##@brief returns a selection of documents from the datasource
96
         if target.is_abstract():
98
         if target.is_abstract():
97
             target_childs = target.child_classes()
99
             target_childs = target.child_classes()
98
             for target_child in target_childs:
100
             for target_child in target_childs:
99
-                results.append(self.select(target=target_child, field_list=field_list, filters=filters,
100
-                                           rel_filters=rel_filters, order=order, group=group, limit=limit,
101
-                                           offset=offset))
101
+                results += self.select(
102
+                    target=target_child, field_list=field_list,
103
+                    filters=filters, rel_filters=rel_filters, order=order,
104
+                    group=group, limit=limit, offset=offset)
102
         else:
105
         else:
103
             # Default arg init
106
             # Default arg init
104
             filters = [] if filters is None else filters
107
             filters = [] if filters is None else filters

Loading…
Cancel
Save