[Checkins] SVN: z3c.rml/trunk/ - Implemented ``color`` directive inside the ``initialize`` directive.

Stephen Richter cvs-admin at zope.org
Fri Dec 21 05:02:18 UTC 2012


Log message for revision 128841:
  - Implemented ``color`` directive inside the ``initialize`` directive.
  

Changed:
  U   z3c.rml/trunk/CHANGES.txt
  U   z3c.rml/trunk/RML-DIFFERENCES.txt
  U   z3c.rml/trunk/src/z3c/rml/document.py
  U   z3c.rml/trunk/src/z3c/rml/tests/expected/tag-color.pdf
  U   z3c.rml/trunk/src/z3c/rml/tests/input/tag-color.rml
  U   z3c.rml/trunk/src/z3c/rml/tests/test_rml.py

-=-
Modified: z3c.rml/trunk/CHANGES.txt
===================================================================
--- z3c.rml/trunk/CHANGES.txt	2012-12-21 04:27:57 UTC (rev 128840)
+++ z3c.rml/trunk/CHANGES.txt	2012-12-21 05:02:18 UTC (rev 128841)
@@ -56,6 +56,8 @@
 
 - Implemented all logging related directives.
 
+- Implemented ``color`` directive inside the ``initialize`` directive.
+
 - Don't show "doc" namespace in reference snippets.
 
 - Create a list of RML2PDF and z3c.rml differences.

Modified: z3c.rml/trunk/RML-DIFFERENCES.txt
===================================================================
--- z3c.rml/trunk/RML-DIFFERENCES.txt	2012-12-21 04:27:57 UTC (rev 128840)
+++ z3c.rml/trunk/RML-DIFFERENCES.txt	2012-12-21 05:02:18 UTC (rev 128841)
@@ -8,6 +8,9 @@
 Incompatibilies
 ---------------
 
+- ``addMapping``: This is a useful API function that was supported in earlier
+  versions of RML2PDF. It is now gone, but this library still supports it.
+
 - ``<barCode>``
 
   * Most barcode attributes available via the API and the flowable are not
@@ -27,21 +30,35 @@
   * `tracking`: This is only used for USPS4S and the API actually uses the
     `value` argument for this. Thus this attribute is omitted.
 
-- ``<keepTogether>``: This directive is not implemented in RML2PDF, but there
-  exists an API flowable for it and it seems obviously useful.
-
 - ``catchForms``: This feature requires PageCatcher, which is a ReportLab
   commercial product and there is no Open Source alternative.
 
-- ``addMapping``: This is a useful API function that was supported in earlier
-  versions of RML2PDF. It is now gone, but this library still supports it.
+- ``docinit``:
 
+  * ``outlineAdd`` directive really does not make much sense here. The API
+    docs claim its availability but the hand-written docs state it must be
+    within a story.
+
+  * ``alias`` directive is completely undocumented in this context.
+
 - ``drawing``: There is no documentation for this tag and I do not know what
   it is supposed to do. Thus z3c.rml does not implement it.
 
+- ``join``: This directive is not implemented due to lack of documentation.
+
+- ``<keepTogether>``: This directive is not implemented in RML2PDF, but there
+  exists an API flowable for it and it seems obviously useful.
+
+- ``length``: This directive is not implemented due to lack of documentation.
+
+- ``template``: The `firstPageTemplate` attribute is not implemented, since it
+  belongs to the ``story`` directive. Several RML2PDF examples use it that way
+  too, so why is it documented differently?
+
 - ``widget``: There is no documentation for this tag and I do not know what it
   is supposed to do. Thus z3c.rml does not implement it.
 
+
 To be Done
 ----------
 
@@ -50,15 +67,7 @@
 denotes a feature not in RML2PDF. The "->" arrow designates a difference in
 naming.
 
-- docinit:
-   * alias
-   * outlineAdd
-   * logConfig
 
-- template: firstPageTemplate
-
-- story: -firstPageTemplate
-
 - pre/xpre: -bulletText, -dedent, -text
 
 - blockTable: -repeatRows, -alignment
@@ -85,16 +94,11 @@
 
 - form
 
-
 - lineMode: -miterLimit
 
-- initialize
-  * color
-
 - paraStyle: fontName -> fontname, fontSize -> fontsize, -keepWithNext,
   -wordWrap, -border*
 
-
 - blockTableStyle: -keepWtihNext
 
 - blockBackground: -colorsByRow, -colorsByCol
@@ -111,9 +115,5 @@
 
 - frame: -*Padding, -showBoundary
 
-- join
-
-- length
-
 - -pdfInclude
 

Modified: z3c.rml/trunk/src/z3c/rml/document.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/document.py	2012-12-21 04:27:57 UTC (rev 128840)
+++ z3c.rml/trunk/src/z3c/rml/document.py	2012-12-21 05:02:18 UTC (rev 128841)
@@ -263,7 +263,15 @@
                 return
         raise ValueError('At least one color definition must be specified.')
 
+# Initialize also supports the <color> tag.
+stylesheet.Initialize.factories['color'] = ColorDefinition
+stylesheet.IInitialize.setTaggedValue(
+    'directives',
+    stylesheet.IInitialize.getTaggedValue('directives') +
+    (occurence.ZeroOrMore('color', IColorDefinition),)
+    )
 
+
 class IStartIndex(interfaces.IRMLDirectiveSignature):
     """Start a new index."""
 

Modified: z3c.rml/trunk/src/z3c/rml/tests/expected/tag-color.pdf
===================================================================
--- z3c.rml/trunk/src/z3c/rml/tests/expected/tag-color.pdf	2012-12-21 04:27:57 UTC (rev 128840)
+++ z3c.rml/trunk/src/z3c/rml/tests/expected/tag-color.pdf	2012-12-21 05:02:18 UTC (rev 128841)
@@ -44,7 +44,7 @@
 % 'R5': class PDFInfo 
 5 0 obj
 << /Author (\(anonymous\))
- /CreationDate (D:20121217140300+05'00')
+ /CreationDate (D:20121220235908+05'00')
  /Creator (\(unspecified\))
  /Keywords ()
  /Producer (ReportLab PDF Library - www.reportlab.com)
@@ -63,9 +63,9 @@
 % page stream
 << /Filter [ /ASCII85Decode
  /FlateDecode ]
- /Length 170 >>
+ /Length 202 >>
 stream
-GappV_$\%5&4Gu<r53bX_:VJj[:_d$?A/7X.99X]_'jnbDn6Y9 at 8:at&uouJh*k^)fH(@[+[(W%6V]Us2,A"$AprtH2r%eB#8_+bAN9i+P&Jnc%K4Njha4&`\PfW'X at p)709jC.qTC8JiI+.]*[raCO:eeLa(Gj_q#S-H,p!~>endstream
+Gat=a]aDV1'SZ9HhVkuD?u191lRM,Z,2<t_`G3 at K)N3P.S&XH\:3$kh3p6AcZ?S/'aoO$0Hm9dLW.m.GJ at 8PnB33C>crGeH`Ysb(Y(b/\Nm"-C=2KNpLllWH9GJ\:\0ajRePjM1Ci5&K&(K^sLSih$nn0%6'@7%B:#]I$0>1ZF%t4/4^223,M[s+HFt^W*p4K\!8Ph`X~>endstream
 endobj
 % 'R8': class PDFOutlines 
 8 0 obj
@@ -82,15 +82,15 @@
 0000000783 00000 n
 0000001052 00000 n
 0000001157 00000 n
-0000001469 00000 n
+0000001501 00000 n
 trailer
 << /ID 
  % ReportLab generated PDF document -- digest (http://www.reportlab.com) 
- [(\2514PW\375b\346M\037u\307 \354\014_\254) (\2514PW\375b\346M\037u\307 \354\014_\254)] 
+ [(.q\250Z\230\301\305<~\027\177\015\311!\235\367) (.q\250Z\230\301\305<~\027\177\015\311!\235\367)] 
 
  /Info 5 0 R
  /Root 4 0 R
  /Size 9 >>
 startxref
-1520
+1552
 %%EOF

Modified: z3c.rml/trunk/src/z3c/rml/tests/input/tag-color.rml
===================================================================
--- z3c.rml/trunk/src/z3c/rml/tests/input/tag-color.rml	2012-12-21 04:27:57 UTC (rev 128840)
+++ z3c.rml/trunk/src/z3c/rml/tests/input/tag-color.rml	2012-12-21 05:02:18 UTC (rev 128841)
@@ -13,9 +13,19 @@
       <frame id="first" x1="1cm" y1="1cm" width="19cm" height="26cm"/>
     </pageTemplate>
   </template>
+
+  <stylesheet>
+    <initialize>
+      <color id="important" value="red" />
+    </initialize>
+  </stylesheet>
+
   <story>
-    <para fontSize="40" textColor="favorite-color">
+    <para fontSize="40" spaceAfter="45" textColor="favorite-color">
       This is my favorite color!
     </para>
+    <para fontSize="40" textColor="important">
+      This is an important color.
+    </para>
   </story>
 </document>

Modified: z3c.rml/trunk/src/z3c/rml/tests/test_rml.py
===================================================================
--- z3c.rml/trunk/src/z3c/rml/tests/test_rml.py	2012-12-21 04:27:57 UTC (rev 128840)
+++ z3c.rml/trunk/src/z3c/rml/tests/test_rml.py	2012-12-21 05:02:18 UTC (rev 128841)
@@ -27,6 +27,8 @@
 except ImportError:
     from PIL import Image
 
+LOG_FILE = os.path.join(os.path.dirname(__file__), 'render.log')
+
 def gs_command(path):
     return ('gs', '-q', '-sNOPAUSE', '-sDEVICE=png256',
             '-sOutputFile=%s[Page-%%d].png' % path[:-4],
@@ -60,10 +62,9 @@
         attr.File.open = self._fileOpen
         del sys.modules['module']
         del sys.modules['mymodule']
-        os.remove(
-            os.path.join(os.path.dirname(__file__), 'render.log'))
+        if os.path.exists(LOG_FILE):
+            os.remove(LOG_FILE)
 
-
     def runTest(self):
         rml2pdf.go(self._inPath, self._outPath)
 



More information about the checkins mailing list