[Zope-Checkins] CVS: Zope/lib/python/Zope/App - startup.py:1.3
Chris McDonough
chrism@zope.com
Sat, 4 Jan 2003 23:07:31 -0500
Update of /cvs-repository/Zope/lib/python/Zope/App
In directory cvs.zope.org:/tmp/cvs-serv5216/App
Modified Files:
startup.py
Log Message:
Use config data for App.startup but still use custom_zodb if it's defined.
=== Zope/lib/python/Zope/App/startup.py 1.2 => 1.3 ===
--- Zope/lib/python/Zope/App/startup.py:1.2 Tue Oct 22 10:23:36 2002
+++ Zope/lib/python/Zope/App/startup.py Sat Jan 4 23:07:29 2003
@@ -31,25 +31,38 @@
import ZPublisher
import ExtensionClass
from zLOG import LOG, WARNING, INFO, BLATHER, log_time
-
+from Zope import Startup
def startup():
+ config = Startup.getConfiguration()
+
global ZODB, app
- Globals.BobobaseName = os.path.join(Globals.data_dir, 'Data.fs')
Globals.DatabaseVersion='3'
# Import products
OFS.Application.import_products()
- # Open the database
+ # Set up a root database from zconfig data
+ zconfig_db = None
+ set_root = 0
+
+ for mount_points, dbfactory in config.databases:
+ # only use root for now
+ if '/' in mount_points:
+ if set_root:
+ raise ConfigurationError, (
+ "Cannot specify more than one 'root' / database"
+ )
+ zconfig_db = dbfactory()
+ Globals.BobobaseName = zconfig_db.getName()
+ set_root = 1
+
try:
- # Try to use custom storage
+ # Root db/storage in custom_zodb overrides zconfig_db
m=imp.find_module('custom_zodb',[INSTANCE_HOME])
except:
- import ZODB.FileStorage
- storage = ZODB.FileStorage.FileStorage(Globals.BobobaseName)
- DB = ZODB.DB(storage)
+ DB = zconfig_db
else:
m=imp.load_module('Zope.custom_zodb', m[0], m[1], m[2])
if hasattr(m,'DB'):
@@ -60,6 +73,9 @@
Globals.BobobaseName = DB.getName()
sys.modules['Zope.custom_zodb']=m
+
+ if DB is None:
+ raise Startup.ConfigurationError, "Must specify a root ('/') database"
if DB.getActivityMonitor() is None:
from ZODB.ActivityMonitor import ActivityMonitor