'Add a :term:`root factory` to the current configuration
state.  If the ``factory`` argument is ``None`` a default root
factory will be registered.
.. note::
Using the ``root_factory`` argument to the
:class:`pyramid.config.Configurator` constructor can be used to
achieve the same purpose.'

@action_method
def set_root_factory(self, factory):

    factory = self.maybe_dotted(factory)
    if (factory is None):
        factory = DefaultRootFactory
    def register():
        self.registry.registerUtility(factory, IRootFactory)
        self.registry.registerUtility(factory, IDefaultRootFactory)
    intr = self.introspectable('root    factories', None, self.object_description(factory), 'root    factory')
    intr['factory'] = factory
    self.action(IRootFactory, register, introspectables=(intr,))
