Bootstrap helpers
=================

The bootstrap helpers provide a number of functions that help with
bootstrapping.

The bootStrapSubscriber function makes sure that there is a root
object.  It subscribes to DatabaseOpened events:

    >>> from zope.app.appsetup import bootstrap
    >>> from zope.app.appsetup import interfaces

    >>> from ZODB.tests import util
    >>> db = util.DB()
    >>> bootstrap.bootStrapSubscriber(interfaces.DatabaseOpened(db))

The subscriber makes ure that there is a root folder:

    >>> from zope.app.publication.zopepublication import ZopePublication
    >>> conn = db.open()
    >>> root = conn.root()[ZopePublication.root_name]
    >>> sm = root.getSiteManager()
    >>> conn.close()
    
A DatabaseOpenedWithRoot is generated with the database.

    >>> from zope.app.event.tests.placelesssetup import getEvents
    >>> [event] = getEvents(interfaces.IDatabaseOpenedWithRootEvent)
    >>> event.database is db
    True

Generally, startup code that expects the root object and site to have
been created will want to subscribe to this event, not
IDataBaseOpenedEvent.

The subscriber generates the event whether or not the root had to be
set up:

    >>> bootstrap.bootStrapSubscriber(interfaces.DatabaseOpened(db))
    >>> [e, event] = getEvents(interfaces.IDatabaseOpenedWithRootEvent)
    >>> event.database is db
    True


