[Zope-Checkins] CVS: Zope/lib/python/DocumentTemplate - DT_Var.py:1.47
Andreas Jung
andreas@zope.com
Fri, 9 Nov 2001 13:52:22 -0500
Update of /cvs-repository/Zope/lib/python/DocumentTemplate
In directory cvs.zope.org:/tmp/cvs-serv16671/lib/python/DocumentTemplate
Modified Files:
DT_Var.py
Log Message:
The function to handle structured text gets both strings and ImplicitAquistion
Wrappers. Calling str() on a IAW called html_quote() that should not be
allowed for DTML Documents and Methods.
=== Zope/lib/python/DocumentTemplate/DT_Var.py 1.46 => 1.47 ===
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'
@@ -419,7 +421,16 @@
global StructuredText
if StructuredText is None:
from StructuredText.StructuredText import HTML
- return HTML(str(v),level=3,header=0)
+
+ 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.