| @@ 48-68 (lines=21) @@ | ||
| 45 | ||
| 46 | return field |
|
| 47 | ||
| 48 | def get(self, name): |
|
| 49 | """Get sample field |
|
| 50 | """ |
|
| 51 | # get the schema field |
|
| 52 | field = self.get_field_by_name(name) |
|
| 53 | ||
| 54 | # check if the field exists |
|
| 55 | if field is None: |
|
| 56 | raise AttributeError("Field '{}' not found".format(name)) |
|
| 57 | ||
| 58 | # Check the permission of the field |
|
| 59 | if not self.is_field_readable(field): |
|
| 60 | raise Unauthorized("Field '{}' not readable!".format(name)) |
|
| 61 | ||
| 62 | # return the value with the field accessor |
|
| 63 | if hasattr(field, "getAccessor"): |
|
| 64 | accessor = field.getAccessor(self.context) |
|
| 65 | return accessor() |
|
| 66 | else: |
|
| 67 | # Set the value on the field directly |
|
| 68 | return field.get(self.context) |
|
| 69 | ||
| 70 | def set_analysis_result(self, name, value): |
|
| 71 | """Handle Batchbook Results |
|
| @@ 48-68 (lines=21) @@ | ||
| 45 | ||
| 46 | return field |
|
| 47 | ||
| 48 | def get(self, name): |
|
| 49 | """Get sample field |
|
| 50 | """ |
|
| 51 | # get the schema field |
|
| 52 | field = self.get_field_by_name(name) |
|
| 53 | ||
| 54 | # check if the field exists |
|
| 55 | if field is None: |
|
| 56 | raise AttributeError("Field '{}' not found".format(name)) |
|
| 57 | ||
| 58 | # Check the permission of the field |
|
| 59 | if not self.is_field_readable(field): |
|
| 60 | raise Unauthorized("Field '{}' not readable!".format(name)) |
|
| 61 | ||
| 62 | # return the value with the field accessor |
|
| 63 | if hasattr(field, "getAccessor"): |
|
| 64 | accessor = field.getAccessor(self.context) |
|
| 65 | return accessor() |
|
| 66 | else: |
|
| 67 | # Set the value on the field directly |
|
| 68 | return field.get(self.context) |
|
| 69 | ||
| 70 | def set(self, name, value): |
|
| 71 | """Set sample field or analysis result |
|