def database(db): """Load ZODB database from Python module or FileStorage file""" if type(db) is str: # Database name if db.endswith('.py'): # Python source, exec it globals = {} execfile(db, globals) if 'DB' in globals: db = globals['DB'] else: storage = globals['Storage'] from ZODB.DB import DB db = DB(storage, cache_size=4000) elif db.endswith(".fs"): from ZODB.FileStorage import FileStorage from ZODB.DB import DB storage = FileStorage(db) db = DB(storage, cache_size=4000) # The following will fail unless the application has been configured. from zope.event import notify notify(zope.processlifetime.DatabaseOpened(db)) return db