fix implementation to avoid separator with nothing following tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 05 May 2009 19:29:59 +0200
branchtls-sprint
changeset 1696 ee0bea49e0e1
parent 1695 9a9822f3cb6c
child 1697 5dae28906769
fix implementation to avoid separator with nothing following
web/box.py
--- a/web/box.py	Tue May 05 19:29:43 2009 +0200
+++ b/web/box.py	Tue May 05 19:29:59 2009 +0200
@@ -173,7 +173,8 @@
         count = self.w_related(box, entity)
         if count:
             box.append(BoxSeparator())
-        self.w_unrelated(box, entity)
+        if not self.w_unrelated(box, entity):
+            del box.items[-1] # remove useless separator
         box.render(self.w)
 
     def div_id(self):
@@ -201,8 +202,11 @@
     def w_unrelated(self, box, entity):
         """appends unrelated entities to the `box`"""
         rql = 'SET S %s O WHERE S eid %%(s)s, O eid %%(o)s' % self.rtype
+        i = 0
         for etarget in self.unrelated_entities(entity):
             box.append(self.box_item(entity, etarget, rql, u'+'))
+            i += 1
+        return i
 
     def unrelated_entities(self, entity):
         """returns the list of unrelated entities