def _apply(self, data):
        '''
        Update an instance from supplied data.

        All fields marked required=True MUST be provided.
        All fields omitted will have their default used, if provided.
        '''
        errors = defaultdict(list)

        for name in self._field_names:
            required = getattr(self._fields[name], 'required', True)
            default = getattr(self._fields[name], 'default', NOT_PROVIDED)

            try:
                value = data[name]
            except KeyError:
                if required:
                    if default is NOT_PROVIDED:
                        errors[name].append(
                            ValidationError('This field is required')
                        )
                        continue
                elif default is NOT_PROVIDED:
                    continue
                value = default
                if callable(value):
                    value = value()
            try:
                setattr(self, name, value)
            except __HOLE__ as e:
                errors[name].append(e)

        self._errors = dict(errors)

        # Allow a final pass of cleaning
        self._clean(data, full=True)

        if self._errors:
            raise ValidationError(self._errors)

        return self._obj
dataset/ETHPy150Open funkybob/django-nap/nap/datamapper/mappers.py/DataMapper._apply