[BlueBream] Loading initial data into DB from paster

Marc Rijken marc at rijken.org
Tue May 24 09:41:59 EDT 2011

Hi Joe,

> What is the preferred way to load initial data into the db?

I have solved this by listening to IDatabaseOpenedEvent and then fill the 
database when certain data is not present. I use the following code for my 
grok applications:

def checkInstalledApplications(event):
    conn = event.database.open()
    root = conn.root()
    approot = root['Application']

    if not app_name in approot:
            #fake request, because request will be used for caching
            request = zope.publisher.browser.TestRequest()

            approot[app_name] = Application()


            #end fake request

Is this you're looking for?



More information about the bluebream mailing list