| @@ 66-86 (lines=21) @@ | ||
| 63 | ||
| 64 | return field |
|
| 65 | ||
| 66 | def get(self, name): |
|
| 67 | """Get sample field |
|
| 68 | """ |
|
| 69 | # get the schema field |
|
| 70 | field = self.get_field_by_name(name) |
|
| 71 | ||
| 72 | # check if the field exists |
|
| 73 | if field is None: |
|
| 74 | raise AttributeError("Field '{}' not found".format(name)) |
|
| 75 | ||
| 76 | # Check the permission of the field |
|
| 77 | if not self.is_field_readable(field): |
|
| 78 | raise Unauthorized("Field '{}' not readable!".format(name)) |
|
| 79 | ||
| 80 | # return the value with the field accessor |
|
| 81 | if hasattr(field, "getAccessor"): |
|
| 82 | accessor = field.getAccessor(self.context) |
|
| 83 | return accessor() |
|
| 84 | else: |
|
| 85 | # Set the value on the field directly |
|
| 86 | return field.get(self.context) |
|
| 87 | ||
| 88 | def set_analysis_result(self, name, value): |
|
| 89 | """Handle Batchbook Results |
|
| @@ 65-85 (lines=21) @@ | ||
| 62 | ||
| 63 | return field |
|
| 64 | ||
| 65 | def get(self, name): |
|
| 66 | """Get sample field |
|
| 67 | """ |
|
| 68 | # get the schema field |
|
| 69 | field = self.get_field_by_name(name) |
|
| 70 | ||
| 71 | # check if the field exists |
|
| 72 | if field is None: |
|
| 73 | raise AttributeError("Field '{}' not found".format(name)) |
|
| 74 | ||
| 75 | # Check the permission of the field |
|
| 76 | if not self.is_field_readable(field): |
|
| 77 | raise Unauthorized("Field '{}' not readable!".format(name)) |
|
| 78 | ||
| 79 | # return the value with the field accessor |
|
| 80 | if hasattr(field, "getAccessor"): |
|
| 81 | accessor = field.getAccessor(self.context) |
|
| 82 | return accessor() |
|
| 83 | else: |
|
| 84 | # Set the value on the field directly |
|
| 85 | return field.get(self.context) |
|
| 86 | ||
| 87 | def set(self, name, value): |
|
| 88 | """Set sample field or analysis result |
|