[Zope3-checkins] CVS: Zope3/lib/python/Zope/App - _app.py:1.5

Guido van Rossum guido@python.org
Thu, 12 Dec 2002 15:16:36 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App
In directory cvs.zope.org:/tmp/cvs-serv31869

Modified Files:
	_app.py 
Log Message:
Refactored the database bootstrapping code: moved this to a separate
module, and use that both from _InitDB() and from _app.py.  Added a
generic feature to set arbitrary attributes of standard services.
Added the error reporting service to the set of standard services, and
set its 'copy to zlog' flag to True.



=== Zope3/lib/python/Zope/App/_app.py 1.4 => 1.5 ===
--- Zope3/lib/python/Zope/App/_app.py:1.4	Thu Oct 24 11:37:02 2002
+++ Zope3/lib/python/Zope/App/_app.py	Thu Dec 12 15:16:34 2002
@@ -17,10 +17,6 @@
 """
 __metaclass__ = type
 
-import base64
-from cStringIO import StringIO
-from Zope.Publisher.Publish import publish as _publish
-
 _configured = 0
 def config(file):
     "Configure site globals"
@@ -63,16 +59,12 @@
             from ZODB.DB import DB
             storage = FileStorage(db)
             db = DB(storage)
-            
-    # Make sure we have an application object
-    connection = db.open()
-    if 'Application' not in connection.root():
-        from Zope.App.OFS.Content.Folder.RootFolder import RootFolder
-        import Transaction
-        connection.root()['Application'] = RootFolder()
-        Transaction.get_transaction().commit()
 
-    connection.close()
+    # XXX When bootstrapping a new database, the following will fail
+    #     while trying to add services when no config_file was passed
+    #     to Application() below.  So, don't do that. :-)
+    from Zope.App.StartUp import bootstrap
+    bootstrap.bootstrapInstance(db)
 
     return db
 
@@ -88,9 +80,13 @@
 
     __browser_pub = None
     __TestRequest = None
+
     def debug(self, path='/', stdin='', stdout=None, basic=None, pm=0,
-              environment = None, **kw):
-        
+              environment=None, **kw):
+        import base64
+        from cStringIO import StringIO
+        from Zope.Publisher.Publish import publish
+
         if stdout is None:
             stdout = StringIO()
 
@@ -115,8 +111,7 @@
         request = self.__TestRequest(stdin, stdout, env)
         request.setPublication(self.__browser_pub)
 
-        _publish(request, handle_errors = not pm)
+        publish(request, handle_errors= not pm)
 
         stdout.seek(0)
         print stdout.read()
-