[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup - run.py:1.1.2.4

Andreas Jung andreas at andreas-jung.com
Fri May 14 08:00:40 EDT 2004


Update of /cvs-repository/Zope/lib/python/Zope/Startup
In directory cvs.zope.org:/tmp/cvs-serv19847/lib/python/Zope/Startup

Modified Files:
      Tag: Zope-2_7-branch
	run.py 
Log Message:
Collector #1233: applied patch introducing $ZOPE_CONFIG to avoid the
necessisty to call Zope.configure() since Zope 2.7.0


=== Zope/lib/python/Zope/Startup/run.py 1.1.2.3 => 1.1.2.4 ===
--- Zope/lib/python/Zope/Startup/run.py:1.1.2.3	Tue Feb  3 15:30:06 2004
+++ Zope/lib/python/Zope/Startup/run.py	Fri May 14 08:00:38 2004
@@ -12,18 +12,24 @@
 #
 ##############################################################################
 
+_zope_opts = None
+
 def run():
     """ Start a Zope instance """
     from Zope.Startup import start_zope
     opts = _setconfig()
     start_zope(opts.configroot)
 
-def configure(configfile):
+def configure(configfile=None):
     """ Provide an API which allows scripts like zopectl to configure
     Zope before attempting to do 'app = Zope.app(). Should be used as
     follows:  from Zope.Startup.run import configure;
     configure('/path/to/configfile'); import Zope; app = Zope.app() """
     from Zope.Startup import ZopeStarter
+    if not configfile:
+        import os
+        configfile = os.getenv('ZOPE_CONFIG', None)
+        del os
     opts = _setconfig(configfile)
     starter = ZopeStarter(opts.configroot)
     starter.setupSecurityOptions()
@@ -35,17 +41,19 @@
     where the configuration file exists. """
     from Zope.Startup import options, handlers
     from App import config
-    opts = options.ZopeOptions()
+    global _zope_opts
+    if _zope_opts: return _zope_opts
+    _zope_opts = options.ZopeOptions()
     if configfile:
-        opts.configfile=configfile
-        opts.realize(doc="Sorry, no option docs yet.", raise_getopt_errs=0)
+        _zope_opts.configfile=configfile
+        _zope_opts.realize(args=[],doc="Sorry, no option docs yet.", 
+                            raise_getopt_errs=0)
     else:
-        opts.realize(doc="Sorry, no option docs yet.")
-        
-    handlers.handleConfig(opts.configroot, opts.confighandlers)
+        _zope_opts.realize(doc="Sorry, no option docs yet.")
+    handlers.handleConfig(_zope_opts.configroot, _zope_opts.confighandlers)
     import App.config
-    App.config.setConfiguration(opts.configroot)
-    return opts
+    App.config.setConfiguration(_zope_opts.configroot)
+    return _zope_opts
 
 if __name__ == '__main__':
     run()




More information about the Zope-Checkins mailing list