Event subscriber for when Plone site is ready

Here's some code I found in a Zope test which shows how to open a db connection and get app from the IDatabaseOpenedWithRoot event:

def logevent(event):
    logger = logging.getLogger('Zope2.App.test_startup')
    logger.info(event.__class__)
    db = event.database
    logger.info(db.__class__)
    conn = db.open()
    try:
        try:
            root = conn.root()
            app = root['Application']
            logger.info(app.__class__)
        except KeyError:
            logger.info('Root not ready.')
    finally:
        conn.close()

Another probably crazy idea: maybe you could register an IBeforeTraverseEvent handler for ISiteRoot which unregisters itself once it's done.

Make sure you think through what happens if there are multiple instances and only one of them restarts. The changes to catalog indexes made by the newly started instance would also be available to the one that didn't restart.