code: def set_fields_from_request(obj, request):
      
      schema = obj.Schema()
      # fields contains all schema-valid field values from the request.
      fields = {}
      for fieldname, value in request.items():
          if fieldname not in schema:
              continue
          field = schema[fieldname]
          widget = field.getWidgetName()
          if widget in ["ReferenceWidget"]:
              brains = []
              if value:
                  brains = resolve_request_lookup(obj, request, fieldname)
                  if not brains:
                      logger.warning(
                          "JSONAPI: Can't resolve reference: {} {}"
                          .format(fieldname, value))
                      return []
              if schema[fieldname].multiValued:
                  value = [b.UID for b in brains] if brains else []
              else:
                  value = brains[0].UID if brains else None
          fields[fieldname] = value
      # Write fields.
      for fieldname, value in fields.items():
          field = schema[fieldname]
          fieldtype = field.getType()
          if fieldtype == 'Products.Archetypes.Field.BooleanField':
              if value.lower() in ('0', 'false', 'no') or not value:
                  value = False
              else:
                  value = True
          elif fieldtype in ['Products.ATExtensions.field.records.RecordsField',
                             'Products.ATExtensions.field.records.RecordField']:
              try:
                  value = eval(value)
              except:
                  logger.warning(
                      "JSONAPI: " + fieldname + ": Invalid "
                      "JSON/Python variable")
                  return []
          mutator = field.getMutator(obj)
          if mutator:
              mutator(value)
          else:
              field.set(obj, value)
      obj.reindexObject()
      return fields.keys()
docs: Search request for keys that match field names in obj,
      and call field mutator with request value.
  
      The list of fields for which schema mutators were found
      is returned.