def WriteArtifact(self, artifact):
    """Writes new artifact to the database."""
    name = str(artifact.name)

    if name in self.artifacts:
      raise db.DuplicatedArtifactError(name)

    self.artifacts[name] = artifact.Copy()