Mercurial > p > roundup > code
comparison roundup/cgi/templating.py @ 3562:a27124aceb69
fix error in link property lookups with numeric-alike key values
[SF#1424550]
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Sun, 12 Feb 2006 13:11:14 +0000 |
| parents | f6719836e521 |
| children | 32343bfc3da0 |
comparison
equal
deleted
inserted
replaced
| 3561:d5661a933cbe | 3562:a27124aceb69 |
|---|---|
| 366 (most likely form values that we wish to represent back to the user) | 366 (most likely form values that we wish to represent back to the user) |
| 367 ''' | 367 ''' |
| 368 cl = db.getclass(prop.classname) | 368 cl = db.getclass(prop.classname) |
| 369 l = [] | 369 l = [] |
| 370 for entry in ids: | 370 for entry in ids: |
| 371 if num_re.match(entry): | 371 try: |
| 372 l.append(entry) | 372 l.append(cl.lookup(entry)) |
| 373 else: | 373 except (TypeError, KeyError): |
| 374 try: | 374 # if fail_ok, ignore lookup error |
| 375 l.append(cl.lookup(entry)) | 375 # otherwise entry must be existing object id rather than key value |
| 376 except (TypeError, KeyError): | 376 if fail_ok or num_re.match(entry): |
| 377 if fail_ok: | 377 l.append(entry) |
| 378 # pass through the bad value | |
| 379 l.append(entry) | |
| 380 return l | 378 return l |
| 381 | 379 |
| 382 def lookupKeys(linkcl, key, ids, num_re=re.compile('^-?\d+$')): | 380 def lookupKeys(linkcl, key, ids, num_re=re.compile('^-?\d+$')): |
| 383 ''' Look up the "key" values for "ids" list - though some may already | 381 ''' Look up the "key" values for "ids" list - though some may already |
| 384 be key values, not ids. | 382 be key values, not ids. |
