add NullActionFlowable, fix empty KeepTogether, version-->3.3.12
authorrobin
Wed, 08 Jun 2016 10:24:06 +0100
changeset 4278 5aa80e7cdba8
parent 4277 838129322a55
child 4279 f69571262c74
add NullActionFlowable, fix empty KeepTogether, version-->3.3.12
src/reportlab/__init__.py
src/reportlab/platypus/__init__.py
src/reportlab/platypus/doctemplate.py
src/reportlab/platypus/flowables.py
tests/test_platypus_general.py
--- a/src/reportlab/__init__.py	Mon Jun 06 14:27:51 2016 +0100
+++ b/src/reportlab/__init__.py	Wed Jun 08 10:24:06 2016 +0100
@@ -1,9 +1,9 @@
 #Copyright ReportLab Europe Ltd. 2000-2016
 #see license.txt for license details
 __doc__="""The Reportlab PDF generation library."""
-Version = "3.3.11"
+Version = "3.3.12"
 __version__=Version
-__date__='20160606'
+__date__='20160608'
 
 import sys, os
 
--- a/src/reportlab/platypus/__init__.py	Mon Jun 06 14:27:51 2016 +0100
+++ b/src/reportlab/platypus/__init__.py	Wed Jun 08 10:24:06 2016 +0100
@@ -13,5 +13,6 @@
 from reportlab.platypus.tables import Table, TableStyle, CellStyle, LongTable
 from reportlab.platypus.frames import Frame
 from reportlab.platypus.doctemplate import BaseDocTemplate, NextPageTemplate, PageTemplate, ActionFlowable, \
-                        SimpleDocTemplate, FrameBreak, PageBegin, Indenter, NotAtTopPageBreak
+                        SimpleDocTemplate, FrameBreak, PageBegin, Indenter, NotAtTopPageBreak, \
+                        NullActionFlowable
 from reportlab.platypus.xpreformatted import XPreformatted
--- a/src/reportlab/platypus/doctemplate.py	Mon Jun 06 14:27:51 2016 +0100
+++ b/src/reportlab/platypus/doctemplate.py	Wed Jun 08 10:24:06 2016 +0100
@@ -157,6 +157,11 @@
     def identity(self, maxLen=None):
         return "ActionFlowable: %s%s" % (str(self.action),self._frameName())
 
+class NullActionFlowable(ActionFlowable):
+    '''an ActionFlowable that does nothing'''
+    def apply(self,doc):
+        pass
+
 class LCActionFlowable(ActionFlowable):
     locChanger = 1                  #we cause a frame or page change
 
--- a/src/reportlab/platypus/flowables.py	Mon Jun 06 14:27:51 2016 +0100
+++ b/src/reportlab/platypus/flowables.py	Wed Jun 08 10:24:06 2016 +0100
@@ -644,6 +644,9 @@
 
 class KeepTogether(_ContainerSpace,Flowable):
     def __init__(self,flowables,maxHeight=None):
+        if not flowables:
+            from reportlab.platypus.doctemplate import NullActionFlowable
+            flowables = [NullActionFlowable()]
         self._content = _flowableSublist(flowables)
         self._maxHeight = maxHeight
 
--- a/tests/test_platypus_general.py	Mon Jun 06 14:27:51 2016 +0100
+++ b/tests/test_platypus_general.py	Wed Jun 08 10:24:06 2016 +0100
@@ -16,7 +16,7 @@
 import copy, sys, os
 from reportlab.pdfgen import canvas
 from reportlab import platypus
-from reportlab.platypus import BaseDocTemplate, PageTemplate, Flowable, FrameBreak
+from reportlab.platypus import BaseDocTemplate, PageTemplate, Flowable, FrameBreak, KeepTogether
 from reportlab.platypus import Paragraph, Preformatted
 from reportlab.lib.units import inch, cm
 from reportlab.lib.styles import PropertySet, getSampleStyleSheet, ParagraphStyle
@@ -197,6 +197,9 @@
     for text in getParagraphs(spam):
         story.append(Paragraph(text, styleSheet['BodyText']))
 
+    #this should not cause an error
+    story.append(KeepTogether([]))
+
     story.append(FrameBreak())
     #######################################################################
     #     Commentary Page 3