index fc0baa454079c1a11e94759ef31d127ab02e9597..c3ab8a18b3f614306df28ac4c97795d813a5ade4 100644 (file)
--- a/roundup/htmltemplate.py
+++ b/roundup/htmltemplate.py
# 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.40 2001-11-03 01:56: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
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
go along with a change.
'''
# TODO: pull the value from the form
- return '<textarea name="__note" rows=%s cols=%s></textarea>'%(rows,
- cols)
+ return '<textarea name="__note" wrap="hard" rows=%s cols=%s>'\
+ '</textarea>'%(rows, cols)
# XXX new function
def do_list(self, property, reverse=0):
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('<form>\n')
- self.filter_section(filter_template, filter, columns, group,
- all_filters, all_columns, show_display_form, show_customization)
- w('</form>\n')
-
- # make sure that the sorting doesn't get lost either
- if sort:
- w('<input type="hidden" name=":sort" value="%s">'%','.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,
l.append(name)
columns = l
+ # display the filter section
+ if (show_display_form and hasattr(self.client, 'FILTER_POSITION') and
+ self.client.FILTER_POSITION in ('top and bottom', 'top')):
+ w('<form action="index">\n')
+ self.filter_section(filter_template, filter, columns, group,
+ all_filters, all_columns, show_customization)
+ # make sure that the sorting doesn't get lost either
+ if sort:
+ w('<input type="hidden" name=":sort" value="%s">'%
+ ','.join(sort))
+ w('</form>\n')
+
+
# now display the index section
w('<table width=100% border=0 cellspacing=0 cellpadding=2>\n')
w('<tr class="list-header">\n')
w('</table>')
# display the filter section
- if (hasattr(self.client, 'FILTER_POSITION') and
+ if (show_display_form and hasattr(self.client, 'FILTER_POSITION') and
self.client.FILTER_POSITION in ('top and bottom', 'bottom')):
- w('<form>\n')
+ w('<form action="index">\n')
self.filter_section(filter_template, filter, columns, group,
- all_filters, all_columns, show_display_form, show_customization)
+ all_filters, all_columns, show_customization)
+ # make sure that the sorting doesn't get lost either
+ if sort:
+ w('<input type="hidden" name=":sort" value="%s">'%
+ ','.join(sort))
w('</form>\n')
def filter_section(self, template, filter, columns, group, all_filters,
- all_columns, show_display_form, show_customization):
+ all_columns, show_customization):
w = self.client.write
for name in self.properties.keys():
if name in all_filters or name in all_columns:
names.append(name)
- w('<tr class="location-bar">')
if show_customization:
action = '-'
else:
if all_columns and name in group:
w('<input type="hidden" name=":group" value="%s">' % name)
- if show_display_form:
- # TODO: The widget style can go into the stylesheet
- w('<th align="left" colspan=%s>'
- '<input style="height : 1em; width : 1em; font-size: 12pt" type="submit" name="action" value="%s"> View '
- 'customisation...</th></tr>\n'%(len(names)+1, action))
- if show_customization:
- w('<tr class="location-bar"><th> </th>')
- for name in names:
- w('<th>%s</th>'%name.capitalize())
- w('</tr>\n')
-
- # Filter
- if all_filters:
- w('<tr><th width="1%" align=right class="location-bar">'
- 'Filters</th>\n')
- for name in names:
- if name not in all_filters:
- w('<td> </td>')
- continue
- if name in filter: checked=' checked'
- else: checked=''
- w('<td align=middle>\n')
- w(' <input type="checkbox" name=":filter" value="%s" '
- '%s></td>\n'%(name, checked))
- w('</tr>\n')
-
- # Columns
- if all_columns:
- w('<tr><th width="1%" align=right class="location-bar">'
- 'Columns</th>\n')
- for name in names:
- if name not in all_columns:
- w('<td> </td>')
- continue
- if name in columns: checked=' checked'
- else: checked=''
- w('<td align=middle>\n')
- w(' <input type="checkbox" name=":columns" value="%s"'
- '%s></td>\n'%(name, checked))
- w('</tr>\n')
-
- # Grouping
- w('<tr><th width="1%" align=right class="location-bar">'
- 'Grouping</th>\n')
- for name in names:
- prop = self.properties[name]
- if name not in all_columns:
- w('<td> </td>')
- continue
- if name in group: checked=' checked'
- else: checked=''
- w('<td align=middle>\n')
- w(' <input type="checkbox" name=":group" value="%s"'
- '%s></td>\n'%(name, checked))
- w('</tr>\n')
-
- w('<tr class="location-bar"><td width="1%"> </td>')
- w('<td colspan="%s">'%len(names))
- w('<input type="submit" name="action" value="Redisplay"></td>')
- w('</tr>\n')
+ # TODO: The widget style can go into the stylesheet
+ w('<th align="left" colspan=%s>'
+ '<input style="height : 1em; width : 1em; font-size: 12pt" type="submit" name="action" value="%s"> View '
+ 'customisation...</th></tr>\n'%(len(names)+1, action))
+ if not show_customization:
w('</table>\n')
+ w('<tr class="location-bar"><th> </th>')
+ for name in names:
+ w('<th>%s</th>'%name.capitalize())
+ w('</tr>\n')
+
+ # Filter
+ if all_filters:
+ w('<tr><th width="1%" align=right class="location-bar">'
+ 'Filters</th>\n')
+ for name in names:
+ if name not in all_filters:
+ w('<td> </td>')
+ continue
+ if name in filter: checked=' checked'
+ else: checked=''
+ w('<td align=middle>\n')
+ w(' <input type="checkbox" name=":filter" value="%s" '
+ '%s></td>\n'%(name, checked))
+ w('</tr>\n')
+
+ # Columns
+ if all_columns:
+ w('<tr><th width="1%" align=right class="location-bar">'
+ 'Columns</th>\n')
+ for name in names:
+ if name not in all_columns:
+ w('<td> </td>')
+ continue
+ if name in columns: checked=' checked'
+ else: checked=''
+ w('<td align=middle>\n')
+ w(' <input type="checkbox" name=":columns" value="%s"'
+ '%s></td>\n'%(name, checked))
+ w('</tr>\n')
+
+ # Grouping
+ w('<tr><th width="1%" align=right class="location-bar">'
+ 'Grouping</th>\n')
+ for name in names:
+ prop = self.properties[name]
+ if name not in all_columns:
+ w('<td> </td>')
+ continue
+ if name in group: checked=' checked'
+ else: checked=''
+ w('<td align=middle>\n')
+ w(' <input type="checkbox" name=":group" value="%s"'
+ '%s></td>\n'%(name, checked))
+ w('</tr>\n')
+
+ w('<tr class="location-bar"><td width="1%"> </td>')
+ w('<td colspan="%s">'%len(names))
+ w('<input type="submit" name="action" value="Redisplay"></td>')
+ w('</tr>\n')
+ w('</table>\n')
+
+
def sortby(self, sort_name, filterspec, columns, filter, group, sort):
l = []
w = l.append
#
# $Log: not supported by cvs2svn $
+# Revision 1.39 2001/11/03 01:43:47 richard
+# Ahah! Fixed the lynx problem - there was a hidden input field misplaced.
+#
+# Revision 1.38 2001/10/31 06:58:51 richard
+# Added the wrap="hard" attribute to the textarea of the note field so the
+# messages wrap sanely.
+#
+# Revision 1.37 2001/10/31 06:24:35 richard
+# Added do_stext to htmltemplate, thanks Brad Clements.
+#
+# Revision 1.36 2001/10/28 22:51:38 richard
+# Fixed ENOENT/WindowsError thing, thanks Juergen Hermann
+#
+# Revision 1.35 2001/10/24 00:04:41 richard
+# Removed the "infinite authentication loop", thanks Roch'e
+#
+# Revision 1.34 2001/10/23 22:56:36 richard
+# Bugfix in filter "widget" placement, thanks Roch'e
+#
+# Revision 1.33 2001/10/23 01:00:18 richard
+# Re-enabled login and registration access after lopping them off via
+# disabling access for anonymous users.
+# Major re-org of the htmltemplate code, cleaning it up significantly. Fixed
+# a couple of bugs while I was there. Probably introduced a couple, but
+# things seem to work OK at the moment.
+#
# Revision 1.32 2001/10/22 03:25:01 richard
# Added configuration for:
# . anonymous user access and registration (deny/allow)