Commit c80c7635 authored by Florent Guillaume's avatar Florent Guillaume

Merged 41303 from 2.9 branch:

When a database is created "by hand" from a custom_zodb.py during
startup, we still want to put it in the dbtab multidatabases dict.

This happens when unit tests call Zope2.startup(), because Testing has a
specific custom_zodb.py loaded at startup that uses a DemoStorage.
parent 2ffd2c28
......@@ -44,28 +44,31 @@ def startup():
# 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',[getConfiguration().testinghome])
m=imp.find_module('custom_zodb',[configuration.testinghome])
except:
m=imp.find_module('custom_zodb',[getConfiguration().instancehome])
m=imp.find_module('custom_zodb',[configuration.instancehome])
except:
# if there is no custom_zodb, use the config file specified databases
configuration = getConfiguration()
DB = configuration.dbtab.getDatabase('/', is_root=1)
Globals.BobobaseName = DB.getName()
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
if hasattr(m,'DB'):
DB=m.DB
dbtab.databases.update(getattr(DB, 'databases', {}))
DB.databases = dbtab.databases
else:
storage = m.Storage
DB = ZODB.DB(storage)
DB = ZODB.DB(m.Storage, databases=dbtab.databases)
Globals.BobobaseName = DB.getName()
sys.modules['Zope2.custom_zodb']=m
if DB.getActivityMonitor() is None:
from ZODB.ActivityMonitor import ActivityMonitor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment