def read(self, fields=None, load='_classic_read'): # determine whether reified groups fields are required, and which ones fields1 = fields or list(self.fields_get()) group_fields, other_fields = partition(is_reified_group, fields1) # read regular fields (other_fields); add 'groups_id' if necessary drop_groups_id = False if group_fields and fields: if 'groups_id' not in other_fields: other_fields.append('groups_id') drop_groups_id = True else: other_fields = fields res = super(UsersView, self).read(other_fields, load=load) # post-process result to add reified group fields if group_fields: for values in res: self._add_reified_groups(group_fields, values) if drop_groups_id: values.pop('groups_id', None) return res
def default_get(self, fields): group_fields, fields = partition(is_reified_group, fields) fields1 = (fields + ['groups_id']) if group_fields else fields values = super(UsersView, self).default_get(fields1) self._add_reified_groups(group_fields, values) return values