Skip to content

Commit 1d87e46

Browse files
author
Richard Jones
committed
Added do_stext to htmltemplate, thanks Brad Clements.
1 parent 52c699b commit 1d87e46

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

roundup/htmltemplate.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: htmltemplate.py,v 1.36 2001-10-28 22:51:38 richard Exp $
18+
# $Id: htmltemplate.py,v 1.37 2001-10-31 06:24:35 richard Exp $
1919

2020
import os, re, StringIO, urllib, cgi, errno
2121

2222
import hyperdb, date, password
2323

24+
# This imports the StructureText functionality for the do_stext function
25+
# get it from http://dev.zope.org/Members/jim/StructuredTextWiki/NGReleases
26+
try:
27+
from StructuredText.StructuredText import HTML as StructuredText
28+
except ImportError:
29+
StructuredText = None
30+
31+
2432
class TemplateFunctions:
2533
def __init__(self):
2634
self.form = None
@@ -74,6 +82,15 @@ def do_plain(self, property, escape=0):
7482
return cgi.escape(value)
7583
return value
7684

85+
def do_stext(self, property, escape=0):
86+
'''Render as structured text using the StructuredText module
87+
(see above for details)
88+
'''
89+
s = self.do_plain(property, escape=escape)
90+
if not StructuredText:
91+
return s
92+
return StructuredText(s,level=1,header=0)
93+
7794
def do_field(self, property, size=None, height=None, showid=0):
7895
''' display a property like the plain displayer, but in a text field
7996
to be edited
@@ -827,6 +844,9 @@ def render(self, form):
827844

828845
#
829846
# $Log: not supported by cvs2svn $
847+
# Revision 1.36 2001/10/28 22:51:38 richard
848+
# Fixed ENOENT/WindowsError thing, thanks Juergen Hermann
849+
#
830850
# Revision 1.35 2001/10/24 00:04:41 richard
831851
# Removed the "infinite authentication loop", thanks Roch'e
832852
#

0 commit comments

Comments
 (0)