1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: htmltemplate.py,v 1.73 2002-02-15 07: 08:44 richard Exp $
18+ # $Id: htmltemplate.py,v 1.74 2002-02-16 08:39:42 richard Exp $
1919
2020__doc__ = """
2121Template engine.
2222"""
2323
24- import os , re , StringIO , urllib , cgi , errno
24+ import os , re , StringIO , urllib , cgi , errno , types
2525
2626import hyperdb , date , password
2727from i18n import _
@@ -257,20 +257,17 @@ def do_menu(self, property, size=None, height=None, showid=0):
257257 value = self .determine_value (property )
258258
259259 # display
260- if isinstance (propclass , hyperdb .Link ):
260+ if isinstance (propclass , hyperdb .Multilink ):
261261 linkcl = self .db .classes [propclass .classname ]
262- l = ['<select name="%s">' % property ]
263- k = linkcl .labelprop ()
264- s = ''
265- if value is None :
266- s = 'selected '
267- l .append (_ ('<option %svalue="-1">- no selection -</option>' )% s )
268262 options = linkcl .list ()
269263 options .sort (sortfunc )
264+ height = height or min (len (options ), 7 )
265+ l = ['<select multiple name="%s" size="%s">' % (property , height )]
266+ k = linkcl .labelprop ()
270267 for optionid in options :
271268 option = linkcl .get (optionid , k )
272269 s = ''
273- if optionid == value :
270+ if optionid in value :
274271 s = 'selected '
275272 if showid :
276273 lab = '%s%s: %s' % (propclass .classname , optionid , option )
@@ -279,20 +276,27 @@ def do_menu(self, property, size=None, height=None, showid=0):
279276 if size is not None and len (lab ) > size :
280277 lab = lab [:size - 3 ] + '...'
281278 lab = cgi .escape (lab )
282- l .append ('<option %svalue="%s">%s</option>' % (s , optionid , lab ))
279+ l .append ('<option %svalue="%s">%s</option>' % (s , optionid ,
280+ lab ))
283281 l .append ('</select>' )
284282 return '\n ' .join (l )
285- if isinstance (propclass , hyperdb .Multilink ):
283+ if isinstance (propclass , hyperdb .Link ):
284+ # force the value to be a single choice
285+ if type (value ) is types .ListType :
286+ value = value [0 ]
286287 linkcl = self .db .classes [propclass .classname ]
288+ l = ['<select name="%s">' % property ]
289+ k = linkcl .labelprop ()
290+ s = ''
291+ if value is None :
292+ s = 'selected '
293+ l .append (_ ('<option %svalue="-1">- no selection -</option>' )% s )
287294 options = linkcl .list ()
288295 options .sort (sortfunc )
289- height = height or min (len (options ), 7 )
290- l = ['<select multiple name="%s" size="%s">' % (property , height )]
291- k = linkcl .labelprop ()
292296 for optionid in options :
293297 option = linkcl .get (optionid , k )
294298 s = ''
295- if optionid in value :
299+ if optionid == value :
296300 s = 'selected '
297301 if showid :
298302 lab = '%s%s: %s' % (propclass .classname , optionid , option )
@@ -301,8 +305,7 @@ def do_menu(self, property, size=None, height=None, showid=0):
301305 if size is not None and len (lab ) > size :
302306 lab = lab [:size - 3 ] + '...'
303307 lab = cgi .escape (lab )
304- l .append ('<option %svalue="%s">%s</option>' % (s , optionid ,
305- lab ))
308+ l .append ('<option %svalue="%s">%s</option>' % (s , optionid , lab ))
306309 l .append ('</select>' )
307310 return '\n ' .join (l )
308311 return _ ('[Menu: not a link]' )
@@ -768,7 +771,8 @@ def render(self, filterspec={}, filter=[], columns=[], sort=[], group=[],
768771 for nodeid in nodeids :
769772 # check for a group heading
770773 if group_names :
771- this_group = [self .cl .get (nodeid , name , _ ('[no value]' )) for name in group_names ]
774+ this_group = [self .cl .get (nodeid , name , _ ('[no value]' ))
775+ for name in group_names ]
772776 if this_group != old_group :
773777 l = []
774778 for name in group_names :
@@ -1064,6 +1068,10 @@ def render(self, form):
10641068
10651069#
10661070# $Log: not supported by cvs2svn $
1071+ # Revision 1.73 2002/02/15 07:08:44 richard
1072+ # . Alternate email addresses are now available for users. See the MIGRATION
1073+ # file for info on how to activate the feature.
1074+ #
10671075# Revision 1.72 2002/02/14 23:39:18 richard
10681076# . All forms now have "double-submit" protection when Javascript is enabled
10691077# on the client-side.
0 commit comments