[Checkins] SVN: z3c.rml/trunk/src/z3c/rml/ Got 2 more RML testsuite files working.

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Mar 16 04:14:12 EDT 2007


Log message for revision 73213:
  Got 2 more RML testsuite files working.
  

Changed:
  U   z3c.rml/trunk/src/z3c/rml/flowable.py
  A   z3c.rml/trunk/src/z3c/rml/tests/input/rml-examples-009-splitting.rml
  A   z3c.rml/trunk/src/z3c/rml/tests/input/rml-examples-010-linkURL.rml
  A   z3c.rml/trunk/src/z3c/rml/tests/module.py
  U   z3c.rml/trunk/src/z3c/rml/tests/test_rml.py

-=-
Modified: z3c.rml/trunk/src/z3c/rml/flowable.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/flowable.py	2007-03-16 07:19:18 UTC (rev 73212)
+++ z3c.rml/trunk/src/z3c/rml/flowable.py	2007-03-16 08:14:11 UTC (rev 73213)
@@ -74,7 +74,10 @@
         modulePath, functionName, text = self.getPositionalArguments()
         module = __import__(modulePath, {}, {}, [modulePath])
         function = getattr(module, functionName)
-        self.parent.flow.append(function(text))
+        flowables = function(text)
+        if not isinstance(flowables, (tuple, list)):
+            flowables = [flowables]
+        self.parent.flow += list(flowables)
 
 class Paragraph(Flowable):
     klass = reportlab.platypus.Paragraph
@@ -387,7 +390,7 @@
         'illustration': Illustration,
         'pre': Preformatted,
         'xpre': XPreformatted,
-        'pluginFlowable': PluginFlowable,
+        'plugInFlowable': PluginFlowable,
         'barCodeFlowable': BarCodeFlowable,
         # Paragraph-Like Flowables
         'title': Title,

Added: z3c.rml/trunk/src/z3c/rml/tests/input/rml-examples-009-splitting.rml
===================================================================
--- z3c.rml/trunk/src/z3c/rml/tests/input/rml-examples-009-splitting.rml	2007-03-16 07:19:18 UTC (rev 73212)
+++ z3c.rml/trunk/src/z3c/rml/tests/input/rml-examples-009-splitting.rml	2007-03-16 08:14:11 UTC (rev 73213)
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="no" ?> 
+<!DOCTYPE document SYSTEM "rml_1_0.dtd"> 
+<document filename="test_009_splitting.pdf"> 
+
+
+<template pageSize="(595, 842)" leftMargin="72" showBoundary="1">
+	<pageTemplate id="main">
+	<pageGraphics>
+		<setFont name="Helvetica-BoldOblique" size="18"/>
+		<drawRightString x="523" y="800">RML2PDF Test Suite - Test #9</drawRightString>
+	</pageGraphics>
+	<frame id="first" x1="1in" y1="5.845in" width="6.27in" height="4in"/>
+	<frame id="second" x1="1in" y1="1in" width="6.27in" height="4in"/>
+	</pageTemplate>
+</template>
+
+<stylesheet>
+	<initialize></initialize>
+
+	<paraStyle name="h1"
+	fontName="Courier-Bold"
+	fontSize="12"
+	spaceBefore = "0.5 cm"
+	/>
+	
+	<paraStyle name="style1"
+	fontName="Courier"
+	fontSize="10"
+	/>
+
+
+	<paraStyle name="heading"
+	fontName="Helvetica-Bold"
+	fontSize="24"
+	leading="28"
+	spaceBefore = "24"
+	/>
+
+	<paraStyle name="head_keep"
+	fontName="Helvetica-Bold"
+	fontSize="24"
+	leading="28"
+	spaceBefore = "24"
+	keepWithNext="1"
+	/>
+
+	<paraStyle name="head_nokeep"
+	fontName="Helvetica-Bold"
+	fontSize="24"
+	leading="28"
+	spaceBefore = "24"
+	keepWithNext="0"
+	/>
+	
+	<paraStyle name="body"
+	fontName="Helvetica"
+	fontSize="12"
+	leading="14"
+	spaceBefore = "3"
+	/>
+	
+
+    <blockTableStyle id="myStyle">
+        <blockAlignment value="center"/>
+        <blockFont name="Helvetica-Oblique"/>
+        <lineStyle kind="GRID" colorName="black"/>
+    </blockTableStyle>
+
+</stylesheet>
+
+
+<story>
+<spacer length="3.65in"/>
+<para style="style1">This page tests splitting - this PARAGRAPH in style 'style1' should
+split between the two frames on this page. This page tests splitting -
+this paragraph should split between the two frames on this page. This
+page tests splitting - this paragraph should split between the two
+frames on this page. This page tests splitting - this paragraph should
+split between the two frames on this page. This page tests splitting -
+this paragraph should split between the two frames on this page.
+</para>
+
+<nextFrame/>
+
+<spacer length="3.65in"/>
+<pre style="style1">This page tests splitting - this PRE in style
+'style1' should split between the two frames on this page. These
+frames should be ON PAGE TWO, otherwise this test has FAILED. This
+page tests splitting - this preformatted paragraph should split between the
+two -- (proves this is a pre)
+frames on this page. This page tests splitting - this pre should
+split between the two frames on this page. This page tests splitting -
+this pre should split between the two frames on this page. This
+page tests splitting - this pre should split between the two
+frames on this page. </pre>
+
+<nextFrame/>
+
+<spacer length="3.65in"/>
+
+<blockTable colWidths="3cm, 3cm,3cm" style="myStyle">
+    <tr>	<td>This tests </td>	<td>how a </td><td>simple table</td></tr>
+    <tr>	<td>splits</td>	<td>across</td><td>frames</td></tr>
+    <tr>	<td>blah</td>	<td>blah</td><td>blah</td></tr>
+</blockTable>
+
+<nextFrame/>
+
+<spacer length="3.65in"/>
+
+<plugInFlowable module="module" function="myPreformatted"/>
+
+
+
+</story>
+
+</document>

Added: z3c.rml/trunk/src/z3c/rml/tests/input/rml-examples-010-linkURL.rml
===================================================================
--- z3c.rml/trunk/src/z3c/rml/tests/input/rml-examples-010-linkURL.rml	2007-03-16 07:19:18 UTC (rev 73212)
+++ z3c.rml/trunk/src/z3c/rml/tests/input/rml-examples-010-linkURL.rml	2007-03-16 08:14:11 UTC (rev 73213)
@@ -0,0 +1,29 @@
+<!-- edited with XML Spy v4.0 U (http://www.xmlspy.com) by Andy Robinson (Reportlab Inc.) -->
+<!DOCTYPE document SYSTEM "rml_1_0.dtd">
+<document filename="test_010_linkURL.pdf">
+	<template pageSize="(595, 842)" leftMargin="72" showBoundary="1">
+	<pageTemplate id="main">
+		<frame id="first" x1="1in" y1="1in" width="6.27in" height="9.69in"/>
+	</pageTemplate>
+	</template>
+	<stylesheet>
+	</stylesheet>
+	<story>
+		<para>These should have links.</para>
+		<blockTable colWidths="5cm,5cm">
+			<blockTableStyle id="temp001">
+				<blockAlignment value="left"/>
+				<blockFont name="Helvetica-Oblique"/>
+				<lineStyle kind="GRID" colorName="black"/>
+				<lineStyle kind="OUTLINE" colorName="black" thickness="2"/>
+				<blockBackground colorName="pink" start="0,0" stop="-1,0"/>
+				<blockBackground colorName="yellow" start="0,0" stop="-1,0"/>
+			</blockTableStyle>
+			<tr><td>Name</td><td>Email</td></tr>
+			<tr>
+				<td>Robin</td>	
+				<td><plugInFlowable module="mymodule" function="linkURL">("mailto:robin at reportlab.com",)</plugInFlowable></td>
+			</tr>
+		</blockTable>
+	</story>
+</document>

Added: z3c.rml/trunk/src/z3c/rml/tests/module.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/tests/module.py	2007-03-16 07:19:18 UTC (rev 73212)
+++ z3c.rml/trunk/src/z3c/rml/tests/module.py	2007-03-16 08:14:11 UTC (rev 73213)
@@ -0,0 +1,51 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTLAR PURPOSE.
+#
+##############################################################################
+"""Testing all XML Locale functionality.
+
+$Id$
+"""
+import reportlab.platypus
+import reportlab.lib.styles
+
+def myPreformatted(params):
+    return reportlab.platypus.Preformatted('''
+        Hey, this is a long text from a plugin. Hey, this is a long text from
+        a plugin. Hey, this is a long text from a plugin. Hey, this is a long
+        text from a plugin. Hey, this is a long text from a plugin. Hey, this
+        is a long text from a plugin. Hey, this is a long text from a
+        plugin. Hey, this is a long text from a plugin. Hey, this is a long
+        text from a plugin. Hey, this is a long text from a plugin. Hey, this
+        is a long text from a plugin. Hey, this is a long text from a
+        plugin. Hey, this is a long text from a plugin. Hey, this is a long
+        text from a plugin. Hey, this is a long text from a plugin. Hey, this
+        is a long text from a plugin.''',
+        reportlab.lib.styles.getSampleStyleSheet()['Normal'])
+
+class LinkURL(reportlab.platypus.flowables.Flowable):
+    def __init__(self, link):
+        self.link = link
+
+    def wrap(self, *args):
+        return (0, 0)
+
+    def draw(self):
+        self.canv.linkURL(self.link, None)
+        
+
+def linkURL(params):
+    params = eval(params)
+    return (
+        reportlab.platypus.Paragraph(
+            params[0], reportlab.lib.styles.getSampleStyleSheet()['Normal']),
+        LinkURL(*params))


Property changes on: z3c.rml/trunk/src/z3c/rml/tests/module.py
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: z3c.rml/trunk/src/z3c/rml/tests/test_rml.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/tests/test_rml.py	2007-03-16 07:19:18 UTC (rev 73212)
+++ z3c.rml/trunk/src/z3c/rml/tests/test_rml.py	2007-03-16 08:14:11 UTC (rev 73213)
@@ -1,6 +1,6 @@
 ##############################################################################
 #
-# Copyright (c) 2002 Zope Corporation and Contributors.
+# Copyright (c) 2007 Zope Corporation and Contributors.
 # All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
@@ -17,6 +17,7 @@
 """
 import os
 import unittest
+import sys
 import z3c.rml.tests
 from z3c.rml import rml2pdf, attr
 
@@ -34,9 +35,14 @@
             path = os.path.join(os.path.dirname(self._inPath), filename)
             return open(path)
         attr.Image.open = testOpen
+        import z3c.rml.tests.module
+        sys.modules['module'] = z3c.rml.tests.module
+        sys.modules['mymodule'] = z3c.rml.tests.module
 
     def tearDown(self):
         attr.Image.open = self._imageOpen
+        del sys.modules['module']
+        del sys.modules['mymodule']
 
     def runTest(self):
         rml2pdf.go(self._inPath, self._outPath)



More information about the Checkins mailing list