[Zope-Checkins] CVS: Zope/lib/python/DocumentTemplate - DT_Var.py:1.41.2.3

Andreas Jung andreas@zope.com
Fri, 9 Nov 2001 14:02:03 -0500


Update of /cvs-repository/Zope/lib/python/DocumentTemplate
In directory cvs.zope.org:/tmp/cvs-serv21050/lib/python/DocumentTemplate

Modified Files:
      Tag: Zope-2_4-branch
	DT_Var.py 
Log Message:

      - <dtml-var "..." fmt="structured-text"> did not work 
        properly under some acquisition related reaons.


=== Zope/lib/python/DocumentTemplate/DT_Var.py 1.41.2.2 => 1.41.2.3 ===
 from cgi import escape
 from html_quote import html_quote # for import by other modules, dont remove!
+from types import StringType
+from Acquisition import aq_base
 
 class Var: 
     name='var'
@@ -411,12 +413,22 @@
 def len_comma(v, name='(Unknown name)', md={}):
     return thousands_commas(str(len(v)))
 
+
 StructuredText=None
 def structured_text(v, name='(Unknown name)', md={}):
     global StructuredText
-    if StructuredText is None: from StructuredText import html_with_references
-    return str(html_with_references(str(v),level=3,header=0))
+    if StructuredText is None: 
+        from StructuredText.StructuredText import HTML
+
+    if isinstance(v,StringType): txt = v
+
+    elif aq_base(v).meta_type in ['DTML Document','DTML Method']:
+        txt = aq_base(v).raw
 
+    else: txt = str(v)
+        
+    return HTML(txt,level=3,header=0)
+        
 def sql_quote(v, name='(Unknown name)', md={}):
     """Quote single quotes in a string by doubling them.