Mercurial > p > roundup > code
comparison roundup/cgi/templating.py @ 2083:a94eacad51c8
handle bad multilink input at item creation time better [SF#917834]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 18 Mar 2004 02:33:15 +0000 |
| parents | ba1d54edc53f |
| children | 62ed6505cbec |
comparison
equal
deleted
inserted
replaced
| 2082:c091cacdc505 | 2083:a94eacad51c8 |
|---|---|
| 290 l.append(cl.lookup(entry)) | 290 l.append(cl.lookup(entry)) |
| 291 except (TypeError, KeyError): | 291 except (TypeError, KeyError): |
| 292 if fail_ok: | 292 if fail_ok: |
| 293 # pass through the bad value | 293 # pass through the bad value |
| 294 l.append(entry) | 294 l.append(entry) |
| 295 return l | |
| 296 | |
| 297 def lookupKeys(linkcl, key, ids, num_re=re.compile('-?\d+')): | |
| 298 ''' Look up the "key" values for "ids" list - though some may already | |
| 299 be key values, not ids. | |
| 300 ''' | |
| 301 l = [] | |
| 302 for entry in ids: | |
| 303 if num_re.match(entry): | |
| 304 l.append(cl.get(entry, key)) | |
| 305 else: | |
| 306 l.append(entry) | |
| 295 return l | 307 return l |
| 296 | 308 |
| 297 class HTMLPermissions: | 309 class HTMLPermissions: |
| 298 ''' Helpers that provide answers to commonly asked Permission questions. | 310 ''' Helpers that provide answers to commonly asked Permission questions. |
| 299 ''' | 311 ''' |
| 1536 # map the id to the label property | 1548 # map the id to the label property |
| 1537 if not linkcl.getkey(): | 1549 if not linkcl.getkey(): |
| 1538 showid=1 | 1550 showid=1 |
| 1539 if not showid: | 1551 if not showid: |
| 1540 k = linkcl.labelprop(1) | 1552 k = linkcl.labelprop(1) |
| 1541 value = [linkcl.get(v, k) for v in value] | 1553 value = lookupKeys(linkcl, k, value) |
| 1542 value = cgi.escape(','.join(value)) | 1554 value = cgi.escape(','.join(value)) |
| 1543 return self.input(name=self._formname,size=size,value=value) | 1555 return self.input(name=self._formname,size=size,value=value) |
| 1544 | 1556 |
| 1545 def menu(self, size=None, height=None, showid=0, additional=[], | 1557 def menu(self, size=None, height=None, showid=0, additional=[], |
| 1546 sort_on=None, **conditions): | 1558 sort_on=None, **conditions): |
