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(): ...@@ -44,28 +44,31 @@ def startup():
# Import products # Import products
OFS.Application.import_products() OFS.Application.import_products()
configuration = getConfiguration()
# Open the database # Open the database
dbtab = configuration.dbtab
try: try:
# Try to use custom storage # Try to use custom storage
try: try:
m=imp.find_module('custom_zodb',[getConfiguration().testinghome]) m=imp.find_module('custom_zodb',[configuration.testinghome])
except: except:
m=imp.find_module('custom_zodb',[getConfiguration().instancehome]) m=imp.find_module('custom_zodb',[configuration.instancehome])
except: except:
# if there is no custom_zodb, use the config file specified databases # if there is no custom_zodb, use the config file specified databases
configuration = getConfiguration() DB = dbtab.getDatabase('/', is_root=1)
DB = configuration.dbtab.getDatabase('/', is_root=1)
Globals.BobobaseName = DB.getName()
else: else:
m=imp.load_module('Zope2.custom_zodb', m[0], m[1], m[2]) m=imp.load_module('Zope2.custom_zodb', m[0], m[1], m[2])
sys.modules['Zope2.custom_zodb']=m
if hasattr(m,'DB'): if hasattr(m,'DB'):
DB=m.DB DB=m.DB
dbtab.databases.update(getattr(DB, 'databases', {}))
DB.databases = dbtab.databases
else: else:
storage = m.Storage DB = ZODB.DB(m.Storage, databases=dbtab.databases)
DB = ZODB.DB(storage)
Globals.BobobaseName = DB.getName() Globals.BobobaseName = DB.getName()
sys.modules['Zope2.custom_zodb']=m
if DB.getActivityMonitor() is None: if DB.getActivityMonitor() is None:
from ZODB.ActivityMonitor import ActivityMonitor 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