[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Zope2/App/startup.py When a database is created "by hand" from a custom_zodb.py during

Florent Guillaume fg at nuxeo.com
Fri Jan 13 11:47:57 EST 2006


Log message for revision 41303:
  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.
  

Changed:
  U   Zope/branches/2.9/lib/python/Zope2/App/startup.py

-=-
Modified: Zope/branches/2.9/lib/python/Zope2/App/startup.py
===================================================================
--- Zope/branches/2.9/lib/python/Zope2/App/startup.py	2006-01-13 16:26:04 UTC (rev 41302)
+++ Zope/branches/2.9/lib/python/Zope2/App/startup.py	2006-01-13 16:47:56 UTC (rev 41303)
@@ -45,28 +45,31 @@
     # 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
+    Globals.BobobaseName = DB.getName()
 
     if DB.getActivityMonitor() is None:
         from ZODB.ActivityMonitor import ActivityMonitor



More information about the Zope-Checkins mailing list