Finds record and update it based in serializer values
160812
def update(self):
        
        obj = self.__model__.objects.get_for_update(id=self.id)
        for name, value in self.__dict__.items():
            if name in self._properties:
                setattr(obj, name, value)
        obj.update()
        return obj
222766
def _update_record(self, identifier, rtype=None, name=None, content=None):
        """"""
        if identifier is not None:
            if name is not None:
                records = self._list_records_internal(identifier=identifier)
                if len(records) == 1 and records[0]['name'] != self._full_name(name):
                    # API does not allow us to update name directly
                    self._update_record_with_name(
                        records[0], rtype, name, content)
                else:
                    self._update_record_with_id(identifier, rtype, content)
            else:
                self._update_record_with_id(identifier, rtype, content)
        else:
            guessed_record = self._guess_record(rtype, name)
            self._update_record_with_id(guessed_record['id'], rtype, content)
        return True
651952
def setRecord(self, record):
        
        self._record = record
        if record is not None:
            self.loadValues(record.recordValues(autoInflate=True))
        else:
            self.loadValues({})
39981
def update_record(self, name, address, ttl=60):
        """"""
        record_id = self._get_record(name)
        if record_id is None:
            return self._create_record(name, address, ttl)
        return self._update_record(record_id, name, address, ttl)
1257762
def _reconstruct_record(self, record_object):
        
        '''  '''
        
        record_details = {}
        current_details = record_details
        for key, value in self.model.keyMap.items():
            record_key = key[1:]
            if record_key:
                record_value = getattr(record_object, record_key, None)
                if record_value != None:
                    record_segments = record_key.split('.')
                    for i in range(len(record_segments)):
                        segment = record_segments[i]
                        if i + 1 < len(record_segments):
                            if segment not in record_details.keys():
                                current_details[segment] = {}
                            current_details = current_details[segment]
                        else:
                            if isinstance(record_value, bytes):
                                current_details[segment] = pickle.loads(record_value)
                            else:
                                current_details[segment] = record_value
                    current_details = record_details
                    
        return record_details
382171
def update(self, data):
        """"""
        if not isinstance(data, list): data = [data] # otherwise no conversion is necessary
        master = Handler.ALL_VERS_DATA
        for record in data:
            #print(record)
            for k,v in iteritems(record): # ensure record contents aretyped appropriately
                try:                record[k] = int(v)
                except ValueError:  record[k] = v
            try: label = record["label"] # verify this record has the required 'label' key
            except KeyError:
                raise ValueError("Must provide a valid label argument.  Given:%s%s"%(\
                    os.linesep, ("%s  "%(os.linesep)).join(
                        ["%15s:%s"%(k,v) for k,v in iteritems(kwargs)]
                    )))
            try:    masterLabel = master[label] # identify the already existing record that matches this to-be-updated record, if any
            except KeyError: # master hasn't been defined yet
                master[label] = record
                self._updated = True # a new record should also be saved
                continue
            for k,v in iteritems(record): # determine whether master needs to be updated
                try:
                    if masterLabel[k] == v:  continue # whether an entry in the record needs to be updated (doesn't match)
                except KeyError:             pass # this condition means that k is a new key, so the record must be updated
                self._updated = True
                try:    master[label].update(record) # index each record by its label
                except KeyError:             break
690206
def reload
      object = self.id.present? ? 
                 persistence_class.where(id: self.id).first_or_initialize : 
                 self

      serialize! object.attributes
    end
1230053
def matchRecordAttrs(mapobj, attrs):
    """"""
    for k,v in iteritems(attrs):
        try:    val = getattr(mapobj, k)
        except AttributeError:       # k isn't an attr of record
            if bool(v): return False # if k doesn't exist in mapobj but was required, no match
            else:       continue     # otherwise ignore attributes that aren't defined for the given map record
        if val != v:    return False # if any criteria matches, it's considered a match
    return True
1246555
def update(self, obj, set_fields = None, unset_fields = None, update_obj = True):
        
        if set_fields:
            if isinstance(set_fields,(list,tuple)):
                set_attributes = {}
                for key in set_fields:
                    try:
                        set_attributes[key] = get_value(obj,key)
                    except KeyError:
                        pass
            else:
                set_attributes = set_fields
        else:
            set_attributes = {}
        if unset_fields:
            unset_attributes = unset_fields
        else:
            unset_attributes = []

        self.call_hook('before_update',obj,set_attributes,unset_attributes)

        if update_obj:
            for key,value in set_attributes.items():
                set_value(obj,key,value)
            for key in unset_attributes:
                delete_value(obj,key)

        return self.save(obj,call_hook = False)
983008
def get_serializer_fields(self, path, method, view):
        
        if method not in ('PUT', 'PATCH', 'POST'):
            return []

        if not hasattr(view, 'get_serializer'):
            return []

        serializer = view.get_serializer()
        if not isinstance(serializer, Serializer):
            return []

        fields = []
        for field in serializer.fields.values():
            if field.read_only or isinstance(field, HiddenField):
                continue

            required = field.required and method != 'PATCH'
            description = force_text(field.help_text) if field.help_text else ''
            field_type = get_field_type(field)
            description += '; ' + field_type if description else field_type
            field = coreapi.Field(
                name=field.field_name,
                location='form',
                required=required,
                description=description,
                schema=schemas.field_to_schema(field),
            )
            fields.append(field)

        return fields
444362
def _record_from_json(value, field):
    """"""
    if _not_null(value, field):
        record = {}
        record_iter = zip(field.fields, value["f"])
        for subfield, cell in record_iter:
            converter = _CELLDATA_FROM_JSON[subfield.field_type]
            if subfield.mode == "REPEATED":
                value = [converter(item["v"], subfield) for item in cell["v"]]
            else:
                value = converter(cell["v"], subfield)
            record[subfield.name] = value
        return record
349384
def serialize(self, root, records):
        """"""
        logging.info("Serializing record")
        logging.debug("Root: {}".format(root))
        logging.debug("Records: {}".format(records))
        if records == {}:
            return '{}'
        if isinstance(records, dict):
            if list(records.keys())[0] == 'errors':
                logging.warning("Found errors. Moving on".format(records))
                root = None
            elif '_id' in records:
                records['id'] = records.pop('_id')
        else:
            records = list(records)

            # rename _id to id
            for r in records:
                if '_id' in r:
                    r['id'] = r.pop('_id')

        if root is not None:
            records = {root: records}
        return json.dumps(records, cls=JSONEncoder)
460538
def handler(event, context):
    
    records = deserialize_records(event['Records'])

    # Split records into two groups, update and delete.
    # We don't want to query for deleted records.
    update_records, delete_records = group_records_by_type(records)
    capture_delete_records(delete_records)

    # filter out error events
    update_records = [e for e in update_records if not e['detail'].get('errorCode')]

    # group records by account for more efficient processing
    log.debug('Update Records: {records}'.format(records=records))

    capture_update_records(update_records)
943716
def update_record(self, identifier, rtype=None, name=None, content=None):  # pylint: disable=too-many-branches
        """"""
        if not identifier:
            records = self.list_records(rtype, name)
            if len(records) == 1:
                identifier = records[0]['id']
            elif len(records) > 1:
                raise Exception('Several record identifiers match the request')
            else:
                raise Exception('Record identifier could not be found')

        identifier = str(identifier)
        version = None

        # Gandi doesn't allow you to edit records on the active zone file.
        # Gandi also doesn't persist zone record identifiers when creating
        # a new zone file. To update by identifier, we lookup the record
        # by identifier, then use the record fields to find the record in
        # the newly created zone.
        records = self._api.domain.zone.record.list(
            self._api_key, self._zone_id, 0, {'id': identifier})

        if len(records) == 1:
            rec = records[0]
            del rec['id']

            try:
                version = self._api.domain.zone.version.new(
                    self._api_key, self._zone_id)
                records = self._api.domain.zone.record.list(
                    self._api_key, self._zone_id, version, rec)
                if len(records) != 1:
                    raise self.GandiInternalError("expected one record")

                if rtype is not None:
                    rec['type'] = rtype.upper()
                if name is not None:
                    rec['name'] = self._relative_name(name)
                if content is not None:
                    rec['value'] = self._txt_encode(
                        content) if rec['type'] == 'TXT' else content

                records = self._api.domain.zone.record.update(
                    self._api_key, self._zone_id, version, {'id': records[0]['id']}, rec)
                if len(records) != 1:
                    raise self.GandiInternalError(
                        "Expected one updated record")

                self._api.domain.zone.version.set(
                    self._api_key, self._zone_id, version)
                ret = True

            except self.GandiInternalError:
                pass

            finally:
                if not ret and version is not None:
                    self._api.domain.zone.version.delete(
                        self._api_key, self._zone_id, version)

        LOGGER.debug("update_record: %s", ret)
        return ret
290167
def _get_record(self):
        
        if not self.pk:
            raise AJAXError(400, _('Invalid request for record.'))

        try:
            return self.model.objects.get(pk=self.pk)
        except self.model.DoesNotExist:
            raise AJAXError(404, _('%s with id of "%s" not found.') % (
                self.model.__name__, self.pk))
1098505
def get_record(self, name):
        

        result = {}
        result.update(self.records.get(name, {}))
        return result
900353
def save_object_to_db(self,
                          obj: Any,
                          table: str,
                          fieldlist: Sequence[str],
                          is_new_record: bool) -> None:
        """"""
        if is_new_record:
            pkvalue = getattr(obj, fieldlist[0])
            if pkvalue is None:
                self.insert_object_into_db_pk_unknown(obj, table, fieldlist)
            else:
                self.insert_object_into_db_pk_known(obj, table, fieldlist)
        else:
            self.update_object_in_db(obj, table, fieldlist)