Browse Source

Quick & dirty workaround for issue #188

We delete all results with the same UID...
Yann Weber 8 years ago
parent
commit
383af4be53
1 changed files with 14 additions and 0 deletions
  1. 14
    0
      lodel/leapi/leobject.py

+ 14
- 0
lodel/leapi/leobject.py View File

@@ -628,8 +628,22 @@ construction and consitency when datas are not complete\n")
628 628
     #@todo broken multiple UID
629 629
     @classmethod
630 630
     def get_from_uid(cls, uid):
631
+        if cls.uid_fieldname() is None:
632
+            raise LodelFatalError(
633
+                "No uid defined for class %s" % cls.__name__)
631 634
         uidname = cls.uid_fieldname()[0] #Brokes composed UID
632 635
         res = cls.get([(uidname,'=', uid)])
636
+        
637
+        #dedoublonnage vu que query ou la datasource est bugué
638
+        if len(res) > 1:
639
+            res_cp = res
640
+            res = []
641
+            while len(res_cp) > 0:
642
+                cur_res = res_cp.pop()
643
+                if cur_res.uid() in [ r.uid() for r in res_cp]:
644
+                    logger.error("DOUBLON detected in query results !!!")
645
+                else:
646
+                    res.append(cur_res)
633 647
         if len(res) > 1:
634 648
             raise LodelFatalError("Get from uid returned more than one \
635 649
 object ! For class %s with uid value = %s" % (cls, uid))

Loading…
Cancel
Save