X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=roundup%2Fhtmltemplate.py;h=1a083b056711fdf9193e0fa013c73145487bd7e1;hb=e6c4c7f8d5631098772610818c9907b51081dac2;hp=fc0baa454079c1a11e94759ef31d127ab02e9597;hpb=23f1d7d802e8806fb76c7d976d4a0efadcaec7cc;p=roundup.git diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index fc0baa4..1a083b0 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -15,12 +15,19 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: htmltemplate.py,v 1.33 2001-10-23 01:00:18 richard Exp $ +# $Id: htmltemplate.py,v 1.38 2001-10-31 06:58:51 richard Exp $ import os, re, StringIO, urllib, cgi, errno import hyperdb, date, password +# This imports the StructureText functionality for the do_stext function +# get it from http://dev.zope.org/Members/jim/StructuredTextWiki/NGReleases +try: + from StructuredText.StructuredText import HTML as StructuredText +except ImportError: + StructuredText = None + class TemplateFunctions: def __init__(self): self.form = None @@ -71,9 +78,18 @@ class TemplateFunctions: else: s = 'Plain: bad propclass "%s"'%propclass if escape: - return cgi.escape(value) + value = cgi.escape(value) return value + def do_stext(self, property, escape=0): + '''Render as structured text using the StructuredText module + (see above for details) + ''' + s = self.do_plain(property, escape=escape) + if not StructuredText: + return s + return StructuredText(s,level=1,header=0) + def do_field(self, property, size=None, height=None, showid=0): ''' display a property like the plain displayer, but in a text field to be edited @@ -370,8 +386,8 @@ class TemplateFunctions: go along with a change. ''' # TODO: pull the value from the form - return ''%(rows, - cols) + return ''%(rows, cols) # XXX new function def do_list(self, property, reverse=0): @@ -483,22 +499,10 @@ class IndexTemplate(TemplateFunctions): self.classname+'.filter')).read() all_filters = self.col_re.findall(filter_template) except IOError, error: - if error.errno != errno.ENOENT: raise + if error.errno not in (errno.ENOENT, errno.ESRCH): raise filter_template = None all_filters = [] - # display the filter section - if (hasattr(self.client, 'FILTER_POSITION') and - self.client.FILTER_POSITION in ('top and bottom', 'top')): - w('
\n') - - # make sure that the sorting doesn't get lost either - if sort: - w(''%','.join(sort)) - # XXX deviate from spec here ... # load the index section template and figure the default columns from it template = open(os.path.join(self.templates, @@ -516,6 +520,18 @@ class IndexTemplate(TemplateFunctions): l.append(name) columns = l + # display the filter section + if (hasattr(self.client, 'FILTER_POSITION') and + self.client.FILTER_POSITION in ('top and bottom', 'top')): + w('\n') + + # make sure that the sorting doesn't get lost either + if sort: + w(''%','.join(sort)) + # now display the index section w('