Set the factory for something.

def set_factory(self, thing: type, value, overwrite=False):
        """
        Set the factory for something.
        """
        if thing in self.factories and not overwrite:
            raise DiayException('factory for %r already exists' % thing)
        self.factories[thing] = value