[Zope3-checkins] SVN: Zope3/branches/philikon-dtml-sync/src/zope/documenttemplate/ Re-enabling fmt=structured-text using the recently ported convenience

Philipp von Weitershausen philikon at philikon.de
Tue Jan 10 12:08:17 EST 2006


Log message for revision 41250:
  Re-enabling fmt=structured-text using the recently ported convenience
  functions in zope.structuredtext.  Includes a simplistic test.
  

Changed:
  U   Zope3/branches/philikon-dtml-sync/src/zope/documenttemplate/dt_var.py
  U   Zope3/branches/philikon-dtml-sync/src/zope/documenttemplate/tests/testdt_var.py

-=-
Modified: Zope3/branches/philikon-dtml-sync/src/zope/documenttemplate/dt_var.py
===================================================================
--- Zope3/branches/philikon-dtml-sync/src/zope/documenttemplate/dt_var.py	2006-01-10 17:07:21 UTC (rev 41249)
+++ Zope3/branches/philikon-dtml-sync/src/zope/documenttemplate/dt_var.py	2006-01-10 17:08:17 UTC (rev 41250)
@@ -148,6 +148,7 @@
 $Id$
 """
 from zope.documenttemplate.dt_util import parse_params, name_param, html_quote
+from zope.structuredtext import stx2htmlWithReferences
 import re, sys
 from urllib import quote, quote_plus
 
@@ -372,12 +373,8 @@
     return thousands_commas(str(len(v)))
 
 
-StructuredText = None
 def structured_text(v, name='(Unknown name)', md={}):
-    global StructuredText
-    if StructuredText is None:
-        import StructuredText
-    return str(StructuredText.html_with_references(str(v), 3))
+    return stx2htmlWithReferences(str(v), level=3, header=0)
 
 
 def sql_quote(v, name='(Unknown name)', md={}):
@@ -395,10 +392,9 @@
     'whole-dollars': whole_dollars,
     'dollars-and-cents': dollars_and_cents,
     'collection-length': len_format,
-    # TODO: Gone for now
-    # 'structured-text': structured_text,
+    'structured-text': structured_text,
 
-    # The rest are depricated:
+    # The rest are deprecated:
     'sql-quote': sql_quote,
     'html-quote': html_quote,
     'url-quote': url_quote,

Modified: Zope3/branches/philikon-dtml-sync/src/zope/documenttemplate/tests/testdt_var.py
===================================================================
--- Zope3/branches/philikon-dtml-sync/src/zope/documenttemplate/tests/testdt_var.py	2006-01-10 17:07:21 UTC (rev 41249)
+++ Zope3/branches/philikon-dtml-sync/src/zope/documenttemplate/tests/testdt_var.py	2006-01-10 17:08:17 UTC (rev 41250)
@@ -42,8 +42,9 @@
             multi:    <dtml-var spam fmt=multi-line>
             dollars:  <dtml-var spam fmt=whole-dollars>
             cents:    <dtml-var spam fmt=dollars-and-cents>
-            dollars,: <dtml-var spam fmt=dollars-with-commas>
-            cents,:   <dtml-var spam fmt=dollars-and-cents-with-commas>
+            dollars:  <dtml-var spam fmt=dollars-with-commas>
+            cents:    <dtml-var spam fmt=dollars-and-cents-with-commas>
+            stx:      <dtml-var spam fmt=structured-text>
 
             """)
 
@@ -55,8 +56,9 @@
             multi:    4200000
             dollars:  $4200000
             cents:    $4200000.00
-            dollars,: $4,200,000
-            cents,:   $4,200,000.00
+            dollars:  $4,200,000
+            cents:    $4,200,000.00
+            stx:      <p>4200000</p>
 
             """)
 
@@ -70,8 +72,9 @@
             multi:    None
             dollars:\x20\x20
             cents:\x20\x20\x20\x20
-            dollars,:\x20
-            cents,:\x20\x20\x20
+            dollars:\x20\x20
+            cents:\x20\x20\x20\x20
+            stx:      <p>None</p>
 
             """)
 
@@ -83,14 +86,16 @@
             multi:    <a href="spam"><br>\nfoo bar
             dollars:\x20\x20
             cents:\x20\x20\x20\x20
-            dollars,:\x20
-            cents,:\x20\x20\x20
+            dollars:\x20\x20
+            cents:\x20\x20\x20\x20
+            stx:      <p><a href="spam">\nfoo bar</p>
 
             """)
 
-        self.assertEqual(html(spam=4200000), result1)
-        self.assertEqual(html(spam=None), result2)
-        self.assertEqual(html(spam=u'<a href="spam">\nfoo bar'), result3)
+        self.assertEqual(html(spam=4200000).strip(), result1.strip())
+        self.assertEqual(html(spam=None).strip(), result2.strip())
+        self.assertEqual(html(spam=u'<a href="spam">\nfoo bar').strip(),
+                         result3.strip())
 
 
     def testRender(self):



More information about the Zope3-Checkins mailing list