reportlab: improve information in doctemplate overflow error
authorrgbecker
Tue, 03 Mar 2009 17:38:41 +0000
changeset 3131 0f15fabe9d8d
parent 3130 0770d19dc052
child 3132 f87241ffab1c
reportlab: improve information in doctemplate overflow error
src/reportlab/platypus/doctemplate.py
src/reportlab/platypus/frames.py
--- a/src/reportlab/platypus/doctemplate.py	Tue Mar 03 15:24:57 2009 +0000
+++ b/src/reportlab/platypus/doctemplate.py	Tue Mar 03 17:38:41 2009 +0000
@@ -48,6 +48,20 @@
 class LayoutError(Exception):
     pass
 
+def _fSizeString(f):
+    w=getattr(f,'width',None)
+    if w is None:
+        w=getattr(f,'_width',None)
+
+    h=getattr(f,'height',None)
+    if h is None:
+        h=getattr(f,'_height',None)
+    if w is not None or h is not None:
+        if w is None: w='???'
+        if h is None: h='???'
+        return '(%s x %s)' % (w,h)
+    return ''
+
 def _doNothing(canvas, doc):
     "Dummy callback for onPage"
     pass
@@ -691,8 +705,9 @@
                         flowables.insert(i,f)   # put split flowables back on the list
                 else:
                     if hasattr(f,'_postponed'):
-                        ident = "Flowable %s too large on page %d in frame '%s' of template '%s'" % \
-                                (self._fIdent(f,60,frame), self.page, self.frame.id, self.pageTemplate.id)
+                        ident = "Flowable %s%s too large on page %d in frame %r%s of template %r" % \
+                                (self._fIdent(f,60,frame),_fSizeString(f),self.page, self.frame.id,
+                                        self.frame._aSpaceString(), self.pageTemplate.id)
                         #leave to keep apart from the raise
                         raise LayoutError(ident)
                     # this ought to be cleared when they are finally drawn!
--- a/src/reportlab/platypus/frames.py	Tue Mar 03 15:24:57 2009 +0000
+++ b/src/reportlab/platypus/frames.py	Tue Mar 03 17:38:41 2009 +0000
@@ -247,3 +247,6 @@
 
     def add_generated_content(self,*C):
         self.__dict__.setdefault('_generated_content',[]).extend(C)
+
+    def _aSpaceString(self):
+        return '(%s x %s%s)' % (self._getAvailableWidth(),self._aH,self._atTop and '*' or '')