web/views/baseviews.py
changeset 1413 ad19d7e6a291
parent 1194 e224f064a268
child 1427 b31f7abc3fdc
child 1590 7f523ae475d2
--- a/web/views/baseviews.py	Mon Apr 20 16:27:08 2009 -0700
+++ b/web/views/baseviews.py	Tue Apr 21 12:08:31 2009 +0200
@@ -158,6 +158,9 @@
         self.render_entity_metadata(entity)
         # entity's attributes and relations, excluding meta data
         # if the entity isn't meta itself
+        boxes = self._preinit_side_related(entity) or siderelations
+        if boxes:
+            self.w(u'<table width="100%"><tr><td width="75%">')
         self.w(u'<div>')
         self.w(u'<div class="mainInfo">')
         self.render_entity_attributes(entity, siderelations)
@@ -166,13 +169,16 @@
         if self.main_related_section:
             self.render_entity_relations(entity, siderelations)
         self.w(u'</div>')
-        # side boxes
-        self.w(u'<div class="primaryRight">')
-        self.render_side_related(entity, siderelations)
-        self.w(u'</div>')
-        self.w(u'<div class="clear"></div>')          
+        if boxes:
+            self.w(u'</td><td>')
+            # side boxes
+            self.w(u'<div class="primaryRight">')
+            self.render_side_related(entity, siderelations)
+            self.w(u'</div>')
+            self.w(u'</td></tr></table>')
         self.content_navigation_components('navcontentbottom')
 
+        
     def content_navigation_components(self, context):
         self.w(u'<div class="%s">' % context)
         for comp in self.vreg.possible_vobjects('contentnavigation',
@@ -255,18 +261,26 @@
                 continue
             self._render_related_entities(entity, rschema, related, x)
 
+    def _preinit_side_related(self, entity):
+        self._sideboxes = None
+        if hasattr(self, 'get_side_boxes_defs'):
+            self._sideboxes = [(label, rset) for label, rset in self.get_side_boxes_defs(entity)
+                               if rset]
+        self._boxes_in_context = list(self.vreg.possible_vobjects('boxes', self.req, self.rset,
+                                                 row=self.row, view=self,
+                                                 context='incontext'))
+        return self._sideboxes or self._boxes_in_context
+        
+            
     def render_side_related(self, entity, siderelations):
         """display side related relations:
         non-meta in a first step, meta in a second step
         """
-        if hasattr(self, 'get_side_boxes_defs'):
-            sideboxes = [(label, rset) for label, rset in self.get_side_boxes_defs(entity)
-                         if rset]
-            if sideboxes:
-                for label, rset in sideboxes:
-                    self.w(u'<div class="sideRelated">')
-                    self.wview('sidebox', rset, title=label)
-                    self.w(u'</div>')
+        if self._sideboxes:
+            for label, rset in self._sideboxes:
+                self.w(u'<div class="sideRelated">')
+                self.wview('sidebox', rset, title=label)
+                self.w(u'</div>')
         elif siderelations:
             self.w(u'<div class="sideRelated">')
             for relatedinfos in siderelations:
@@ -274,11 +288,9 @@
                 #    continue
                 self._render_related_entities(entity, *relatedinfos)
             self.w(u'</div>')
-        boxes = list(self.vreg.possible_vobjects('boxes', self.req, self.rset,
-                                                 row=self.row, view=self,
-                                                 context='incontext'))
-        if boxes:
-            for box in boxes:
+
+        if self._boxes_in_context:
+            for box in self._boxes_in_context:
                 try:
                     box.dispatch(w=self.w, row=self.row)
                 except NotImplementedError: