Mercurial > p > roundup > code
comparison roundup/cgi/templating.py @ 5876:716d50585c8d
Fix Link/Multilink searching
.. for the case that a key property may contain numeric values.
This already was correct for menu (in an item template) but was doing
the wrong thing for index templates.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Mon, 02 Sep 2019 16:11:17 +0200 |
| parents | 883c9e90b403 |
| children | c3728772c594 |
comparison
equal
deleted
inserted
replaced
| 5875:828bbf219e56 | 5876:716d50585c8d |
|---|---|
| 382 know that the value passed *is* an id) | 382 know that the value passed *is* an id) |
| 383 """ | 383 """ |
| 384 cl = db.getclass(prop.classname) | 384 cl = db.getclass(prop.classname) |
| 385 l = [] | 385 l = [] |
| 386 for entry in ids: | 386 for entry in ids: |
| 387 # Do not look up numeric IDs | |
| 388 if num_re.match(entry): | |
| 389 l.append(entry) | |
| 390 continue | |
| 387 if do_lookup: | 391 if do_lookup: |
| 388 try: | 392 try: |
| 389 item = cl.lookup(entry) | 393 item = cl.lookup(entry) |
| 390 except (TypeError, KeyError): | 394 except (TypeError, KeyError): |
| 391 pass | 395 pass |
| 392 else: | 396 else: |
| 393 l.append(item) | 397 l.append(item) |
| 394 continue | 398 continue |
| 395 # if fail_ok, ignore lookup error | 399 # if fail_ok, ignore lookup error |
| 396 # otherwise entry must be existing object id rather than key value | 400 # otherwise entry must be existing object id rather than key value |
| 397 if fail_ok or num_re.match(entry): | 401 if fail_ok: |
| 398 l.append(entry) | 402 l.append(entry) |
| 399 return l | 403 return l |
| 400 | 404 |
| 401 def lookupKeys(linkcl, key, ids, num_re=num_re): | 405 def lookupKeys(linkcl, key, ids, num_re=num_re): |
| 402 """ Look up the "key" values for "ids" list - though some may already | 406 """ Look up the "key" values for "ids" list - though some may already |
