'Set all of the fields specified by the keys of `kv_dict` to the values
in that dict.
Arguments:
kv_dict (dict): dict mapping from `DjangoKeyValueStore.Key`s to field values
Raises: DatabaseError if any fields fail to save'

@contract(kv_dict='dict(DjangoKeyValueStore_Key:    *)')
def set_many(self, kv_dict):

    if self.read_only:
        return
    saved_fields = []
    by_scope = defaultdict(dict)
    for (key, value) in kv_dict.iteritems():
        if ((key.scope.user == UserScope.ONE) and (not self.user.is_anonymous())):
            assert (key.user_id == self.user.id)
        if (key.scope not in self.cache):
            continue
        by_scope[key.scope][key] = value
    for (scope, set_many_data) in by_scope.iteritems():
        try:
            self.cache[scope].set_many(set_many_data)
            saved_fields.extend((key.field_name for key in set_many_data))
        except KeyValueMultiSaveError as exc:
            log.exception('Error    saving    fields    %r', [key.field_name for key in set_many_data])
            raise KeyValueMultiSaveError((saved_fields + exc.saved_field_names))
