|
15 | 15 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
16 | 16 | # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
17 | 17 | # |
18 | | -# $Id: htmltemplate.py,v 1.27 2001-10-20 12:13:44 richard Exp $ |
| 18 | +# $Id: htmltemplate.py,v 1.28 2001-10-21 00:00:16 richard Exp $ |
19 | 19 |
|
20 | 20 | import os, re, StringIO, urllib, cgi, errno |
21 | 21 |
|
@@ -305,27 +305,37 @@ class Checklist(Base): |
305 | 305 | ''' |
306 | 306 | def __call__(self, property, **args): |
307 | 307 | propclass = self.properties[property] |
| 308 | + if (not isinstance(propclass, hyperdb.Link) and not |
| 309 | + isinstance(propclass, hyperdb.Multilink)): |
| 310 | + return '[Checklist: not a link]' |
| 311 | + |
| 312 | + # get our current checkbox state |
308 | 313 | if self.nodeid: |
309 | | - value = self.cl.get(self.nodeid, property) |
| 314 | + # get the info from the node - make sure it's a list |
| 315 | + if isinstance(propclass, hyperdb.Link: |
| 316 | + value = [self.cl.get(self.nodeid, property)] |
| 317 | + else: |
| 318 | + value = self.cl.get(self.nodeid, property) |
310 | 319 | elif self.filterspec is not None: |
| 320 | + # get the state from the filter specification (always a list) |
311 | 321 | value = self.filterspec.get(property, []) |
312 | 322 | else: |
| 323 | + # it's a new node, so there's no state |
313 | 324 | value = [] |
314 | | - if (isinstance(propclass, hyperdb.Link) or |
315 | | - isinstance(propclass, hyperdb.Multilink)): |
316 | | - linkcl = self.db.classes[propclass.classname] |
317 | | - l = [] |
318 | | - k = linkcl.labelprop() |
319 | | - for optionid in linkcl.list(): |
320 | | - option = linkcl.get(optionid, k) |
321 | | - if optionid in value or option in value: |
322 | | - checked = 'checked' |
323 | | - else: |
324 | | - checked = '' |
325 | | - l.append('%s:<input type="checkbox" %s name="%s" value="%s">'%( |
326 | | - option, checked, property, option)) |
327 | | - return '\n'.join(l) |
328 | | - return '[Checklist: not a link]' |
| 325 | + |
| 326 | + # so we can map to the linked node's "lable" property |
| 327 | + linkcl = self.db.classes[propclass.classname] |
| 328 | + l = [] |
| 329 | + k = linkcl.labelprop() |
| 330 | + for optionid in linkcl.list(): |
| 331 | + option = linkcl.get(optionid, k) |
| 332 | + if optionid in value or option in value: |
| 333 | + checked = 'checked' |
| 334 | + else: |
| 335 | + checked = '' |
| 336 | + l.append('%s:<input type="checkbox" %s name="%s" value="%s">'%( |
| 337 | + option, checked, property, option)) |
| 338 | + return '\n'.join(l) |
329 | 339 |
|
330 | 340 | class Note(Base): |
331 | 341 | ''' display a "note" field, which is a text area for entering a note to |
@@ -758,6 +768,9 @@ def newitem(client, templates, db, classname, form, replace=re.compile( |
758 | 768 |
|
759 | 769 | # |
760 | 770 | # $Log: not supported by cvs2svn $ |
| 771 | +# Revision 1.27 2001/10/20 12:13:44 richard |
| 772 | +# Fixed grouping of non-str properties (thanks Roch'e Compaan) |
| 773 | +# |
761 | 774 | # Revision 1.26 2001/10/14 10:55:00 richard |
762 | 775 | # Handle empty strings in HTML template Link function |
763 | 776 | # |
|
0 commit comments