[Checkins] SVN: z3c.rml/trunk/src/z3c/rml/ * KeepInFrame has a bug in ReportLab 2.0 not allowing maxHeight to be

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Apr 4 13:02:37 EDT 2007


Log message for revision 74006:
  * KeepInFrame has a bug in ReportLab 2.0 not allowing maxHeight to be 
    None, even though the wrap() method does the right thing and can handle 
    None and 0, both values disallowed.
  
  * Make sure that we strip the <?xml ?> line only when dealing with a 
    unicode string.
  
  

Changed:
  U   z3c.rml/trunk/src/z3c/rml/flowable.py
  U   z3c.rml/trunk/src/z3c/rml/platypus.py
  U   z3c.rml/trunk/src/z3c/rml/rml2pdf.py

-=-
Modified: z3c.rml/trunk/src/z3c/rml/flowable.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/flowable.py	2007-04-04 16:50:22 UTC (rev 74005)
+++ z3c.rml/trunk/src/z3c/rml/flowable.py	2007-04-04 17:02:37 UTC (rev 74006)
@@ -718,7 +718,7 @@
 
 class KeepInFrame(Flowable):
     signature = IKeepInFrame
-    klass = reportlab.platypus.flowables.KeepInFrame
+    klass = platypus.KeepInFrame
     attrMapping = {'onOverflow': 'mode', 'id': 'name'}
 
     def process(self):

Modified: z3c.rml/trunk/src/z3c/rml/platypus.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/platypus.py	2007-04-04 16:50:22 UTC (rev 74005)
+++ z3c.rml/trunk/src/z3c/rml/platypus.py	2007-04-04 17:02:37 UTC (rev 74006)
@@ -21,7 +21,25 @@
 
 from z3c.rml import interfaces
 
+# Fix problem with reportlab 2.0
+class KeepInFrame(reportlab.platypus.flowables.KeepInFrame):
 
+    def __init__(self, maxWidth, maxHeight, content=[], mergeSpace=1,
+                 mode='shrink', name=''):
+        self.name = name
+        self.maxWidth = maxWidth
+        self.maxHeight = maxHeight
+        self.mode = mode
+        assert mode in ('error','overflow','shrink','truncate'), \
+               '%s invalid mode value %s' % (self.identity(),mode)
+        # This is an unnecessary check, since wrap() handles None just fine!
+        #assert maxHeight>=0,  \
+        #       '%s invalid maxHeight value %s' % (self.identity(),maxHeight)
+        if mergeSpace is None: mergeSpace = overlapAttachedSpace
+        self.mergespace = mergeSpace
+        self._content = content
+
+
 class BaseFlowable(reportlab.platypus.flowables.Flowable):
     def __init__(self, *args, **kw):
         reportlab.platypus.flowables.Flowable.__init__(self)

Modified: z3c.rml/trunk/src/z3c/rml/rml2pdf.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/rml2pdf.py	2007-04-04 16:50:22 UTC (rev 74005)
+++ z3c.rml/trunk/src/z3c/rml/rml2pdf.py	2007-04-04 17:02:37 UTC (rev 74006)
@@ -27,7 +27,7 @@
 
 
 def parseString(xml, removeEncodingLine=True):
-    if removeEncodingLine:
+    if isinstance(xml, unicode) and removeEncodingLine:
         # RML is a unicode string, but oftentimes documents declare their
         # encoding using <?xml ...>. Unfortuantely, I cannot tell lxml to
         # ignore that directive. Thus we remove it.



More information about the Checkins mailing list