'Write the dirty attributes to the data store.'

@utils.Synchronized
def _WriteAttributes(self, sync=True):

    if ('w' not in self.mode):
        return
    if (self.urn is None):
        raise RuntimeError('Storing    of    anonymous    AFF4    objects    not    supported.')
    to_set = {}
    for (attribute_name, value_array) in self.new_attributes.iteritems():
        to_set_list = to_set.setdefault(attribute_name, [])
        for value in value_array:
            to_set_list.append((value.SerializeToDataStore(), value.age))
    if self._dirty:
        if self._new_version:
            to_set[self.Schema.TYPE] = [(utils.SmartUnicode(self.__class__.__name__), rdfvalue.RDFDatetime.Now())]
        add_child_index = self.Schema.ADD_CHILD_INDEX
        if self.object_exists:
            add_child_index = False
        FACTORY.SetAttributes(self.urn, to_set, self._to_delete, add_child_index=add_child_index, mutation_pool=self.mutation_pool, sync=sync, token=self.token)
