Mercurial > p > roundup > code
comparison roundup/rest.py @ 5681:6457fd696a43
Handle bad property name in @fields/@attrs. Raise exception and
provide useful message.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 30 Mar 2019 00:19:37 -0400 |
| parents | f77209ddd579 |
| children | e8ac82b8d074 |
comparison
equal
deleted
inserted
replaced
| 5680:f77209ddd579 | 5681:6457fd696a43 |
|---|---|
| 583 elif key == "@fields" or key == "@attrs": | 583 elif key == "@fields" or key == "@attrs": |
| 584 f = value.split(",") | 584 f = value.split(",") |
| 585 if len(f) == 1: | 585 if len(f) == 1: |
| 586 f=value.split(",") | 586 f=value.split(",") |
| 587 for i in f: | 587 for i in f: |
| 588 display_props[i] = class_obj.properties[i] | 588 try: |
| 589 display_props[i] = class_obj.properties[i] | |
| 590 except KeyError as err: | |
| 591 raise UsageError("Failed to find property '%s' " | |
| 592 "for class %s."%(i, class_name)) | |
| 593 | |
| 594 | |
| 589 else: # serve the filter purpose | 595 else: # serve the filter purpose |
| 590 prop = class_obj.getprops()[key] | 596 prop = class_obj.getprops()[key] |
| 591 # We drop properties without search permission silently | 597 # We drop properties without search permission silently |
| 592 # This reflects the current behavior of other roundup | 598 # This reflects the current behavior of other roundup |
| 593 # interfaces | 599 # interfaces |
| 736 # support , or : separated elements | 742 # support , or : separated elements |
| 737 f=value.split(",") | 743 f=value.split(",") |
| 738 if len(f) == 1: | 744 if len(f) == 1: |
| 739 f=value.split(":") | 745 f=value.split(":") |
| 740 for i in f: | 746 for i in f: |
| 741 props[i] = class_obj.properties[i] | 747 try: |
| 748 props[i] = class_obj.properties[i] | |
| 749 except KeyError as err: | |
| 750 raise UsageError("Failed to find property '%s' for class %s."%(i, class_name)) | |
| 742 elif key == "@protected": | 751 elif key == "@protected": |
| 743 # allow client to request read only | 752 # allow client to request read only |
| 744 # properties like creator, activity etc. | 753 # properties like creator, activity etc. |
| 745 # used only if no @fields/@attrs | 754 # used only if no @fields/@attrs |
| 746 protected = value.lower() == "true" | 755 protected = value.lower() == "true" |
