[Zope-Checkins]
SVN: Zope/trunk/lib/python/DocumentTemplate/DT_Var.py
replace StructuredText module with zope.structuredtext
Andreas Jung
andreas at andreas-jung.com
Sat Jan 7 09:34:38 EST 2006
Log message for revision 41185:
replace StructuredText module with zope.structuredtext
Changed:
U Zope/trunk/lib/python/DocumentTemplate/DT_Var.py
-=-
Modified: Zope/trunk/lib/python/DocumentTemplate/DT_Var.py
===================================================================
--- Zope/trunk/lib/python/DocumentTemplate/DT_Var.py 2006-01-07 14:10:26 UTC (rev 41184)
+++ Zope/trunk/lib/python/DocumentTemplate/DT_Var.py 2006-01-07 14:34:38 UTC (rev 41185)
@@ -154,15 +154,18 @@
__rcs_id__='$Id$'
__version__='$Revision: 1.60 $'[11:-2]
+from cgi import escape
+import string, re, sys
+from urllib import quote, quote_plus, unquote, unquote_plus
from DT_Util import parse_params, name_param, str, ustr
-import os, string, re, sys
-from urllib import quote, quote_plus, unquote, unquote_plus
-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
from ZPublisher.TaintedString import TaintedString
+from zope.structuredtext.html import HTMLWithImages, HTML
+from zope.structuredtext.document import DocumentWithImages
+from App.config import getConfiguration
+
class Var:
name='var'
expr=None
@@ -400,32 +403,30 @@
from reStructuredText import HTML
- if isinstance(v,StringType): txt = v
+ if isinstance(v, str):
+ txt = v
elif aq_base(v).meta_type in ['DTML Document','DTML Method']:
txt = aq_base(v).read_raw()
- else: txt = str(v)
+ else:
+ txt = str(v)
return HTML(txt)
-StructuredText=None
def structured_text(v, name='(Unknown name)', md={}):
- global StructuredText
- if StructuredText is None:
- from StructuredText.StructuredText import HTML
- if isinstance(v,StringType): txt = v
-
+ if isinstance(v, str):
+ txt = v
elif aq_base(v).meta_type in ['DTML Document','DTML Method']:
txt = aq_base(v).read_raw()
+ else:
+ txt = str(v)
- else: txt = str(v)
+ level = getConfiguration().structured_text_header_level
+ doc = DocumentWithImages()(txt)
+ return HTML()(doc, level, header=False)
- return HTML(txt,
- level=int(os.environ.get('STX_DEFAULT_LEVEL',3)),
- header=0)
-
def sql_quote(v, name='(Unknown name)', md={}):
"""Quote single quotes in a string by doubling them.
More information about the Zope-Checkins
mailing list