def startup(): from Zope2.App import patches patches.apply_patches() global app # Import products OFS.Application.import_products() configuration = getConfiguration() # Open the database dbtab = configuration.dbtab DB = None custom_locations = [ getattr(configuration, 'testinghome', None), configuration.instancehome, ] for location in custom_locations: if not location: continue module = _load_custom_zodb(location) if module is not None: # Get the database and join it to the dbtab multidatabase # FIXME: this uses internal datastructures of dbtab databases = getattr(dbtab, 'databases', {}) if hasattr(module, 'DB'): DB = module.DB databases.update(getattr(DB, 'databases', {})) DB.databases = databases else: DB = ZODB.DB(module.Storage, databases=databases) break else: # if there is no custom_zodb, use the config file specified databases DB = dbtab.getDatabase('/', is_root=1) # Force a connection to every configured database, to ensure all of them # can indeed be opened. This avoids surprises during runtime when traversal # to some database mountpoint fails as the underlying storage cannot be # opened at all if dbtab is not None: for mount, name in dbtab.listMountPaths(): _db = dbtab.getDatabase(mount) _conn = _db.open() _conn.close() del _conn del _db notify(DatabaseOpened(DB)) Zope2.DB = DB Zope2.opened.append(DB) from . import ClassFactory DB.classFactory = ClassFactory.ClassFactory # "Log on" as system user newSecurityManager(None, AccessControl.User.system) # Set up the CA load_zcml() # Set up the "app" object that automagically opens # connections app = App.ZApplication.ZApplicationWrapper(DB, 'Application', OFS.Application.Application) Zope2.bobo_application = app # Initialize the app object application = app() OFS.Application.initialize(application) application._p_jar.close() # "Log off" as system user noSecurityManager() global startup_time startup_time = asctime() notify(DatabaseOpenedWithRoot(DB))
def startup(): from Zope2.App import patches patches.apply_patches() global app # Import products OFS.Application.import_products() configuration = getConfiguration() # Open the database dbtab = configuration.dbtab DB = None custom_locations = [ getattr(configuration, 'testinghome', None), configuration.instancehome, ] for location in custom_locations: if not location: continue module = _load_custom_zodb(location) if module is not None: # Get the database and join it to the dbtab multidatabase # FIXME: this uses internal datastructures of dbtab databases = getattr(dbtab, 'databases', {}) if hasattr(module, 'DB'): DB = module.DB databases.update(getattr(DB, 'databases', {})) DB.databases = databases else: DB = ZODB.DB(module.Storage, databases=databases) break else: # if there is no custom_zodb, use the config file specified databases DB = dbtab.getDatabase('/', is_root=1) # Force a connection to every configured database, to ensure all of them # can indeed be opened. This avoids surprises during runtime when traversal # to some database mountpoint fails as the underlying storage cannot be # opened at all if dbtab is not None: for mount, name in dbtab.listMountPaths(): _db = dbtab.getDatabase(mount) _conn = _db.open() _conn.close() del _conn del _db notify(DatabaseOpened(DB)) Zope2.DB = DB Zope2.opened.append(DB) from . import ClassFactory DB.classFactory = ClassFactory.ClassFactory # "Log on" as system user newSecurityManager(None, AccessControl.User.system) # Set up the CA load_zcml() # Set up the "app" object that automagically opens # connections app = App.ZApplication.ZApplicationWrapper( DB, 'Application', OFS.Application.Application) Zope2.bobo_application = app # Initialize the app object application = app() OFS.Application.initialize(application) application._p_jar.close() # "Log off" as system user noSecurityManager() global startup_time startup_time = asctime() notify(DatabaseOpenedWithRoot(DB))
def startup(): from App.PersistentExtra import patchPersistent import Globals # to set / fetch data patchPersistent() from Zope2.App import patches patches.apply_patches() global app # Import products OFS.Application.import_products() configuration = getConfiguration() # Open the database dbtab = configuration.dbtab try: # Try to use custom storage try: m = imp.find_module('custom_zodb', [configuration.testinghome]) except: m = imp.find_module('custom_zodb', [configuration.instancehome]) except Exception: # if there is no custom_zodb, use the config file specified databases DB = dbtab.getDatabase('/', is_root=1) else: m = imp.load_module('Zope2.custom_zodb', m[0], m[1], m[2]) sys.modules['Zope2.custom_zodb'] = m # Get the database and join it to the dbtab multidatabase # FIXME: this uses internal datastructures of dbtab databases = getattr(dbtab, 'databases', {}) if hasattr(m, 'DB'): DB = m.DB databases.update(getattr(DB, 'databases', {})) DB.databases = databases else: DB = ZODB.DB(m.Storage, databases=databases) notify(DatabaseOpened(DB)) Globals.BobobaseName = DB.getName() if DB.getActivityMonitor() is None: from ZODB.ActivityMonitor import ActivityMonitor DB.setActivityMonitor(ActivityMonitor()) Globals.DB = DB Zope2.DB = DB # Hook for providing multiple transaction object manager undo support: Globals.UndoManager = DB Globals.opened.append(DB) import ClassFactory DB.classFactory = ClassFactory.ClassFactory # "Log on" as system user newSecurityManager(None, AccessControl.User.system) # Set up the CA load_zcml() # Set up the "app" object that automagically opens # connections app = App.ZApplication.ZApplicationWrapper(DB, 'Application', OFS.Application.Application, ()) Zope2.bobo_application = app # Initialize the app object application = app() OFS.Application.initialize(application) if Globals.DevelopmentMode: # Set up auto-refresh. from App.RefreshFuncs import setupAutoRefresh setupAutoRefresh(application._p_jar) application._p_jar.close() # "Log off" as system user noSecurityManager() global startup_time startup_time = asctime() notify(DatabaseOpenedWithRoot(DB)) Zope2.zpublisher_transactions_manager = TransactionsManager() Zope2.zpublisher_exception_hook = zpublisher_exception_hook Zope2.zpublisher_validated_hook = validated_hook Zope2.__bobo_before__ = noSecurityManager