Index: __init__.py =================================================================== --- __init__.py (revision 39858) +++ __init__.py (working copy) @@ -28,13 +28,17 @@ logger = logging.getLogger("Zope") started = False +starter = None def get_starter(): - check_python_version() - if sys.platform[:3].lower() == "win": - return WindowsZopeStarter() - else: - return UnixZopeStarter() + global starter + if starter is None: + check_python_version() + if sys.platform[:3].lower() == "win": + starter = WindowsZopeStarter() + else: + starter = UnixZopeStarter() + return starter def start_zope(cfg, debug_handler): """The function called by run.py which starts a Zope appserver.""" @@ -47,11 +51,11 @@ starter.setConfiguration(cfg) starter.prepare() - started = True + starter.start() try: starter.run() finally: - started = False + starter.finish() class ZopeStarter: @@ -59,6 +63,8 @@ Making it a class makes it easier to test. """ + started = False + def __init__(self): self.event_logger = logging.getLogger() # We log events to the root logger, which is backed by a @@ -81,6 +87,14 @@ def setConfiguration(self, cfg): self.cfg = cfg + def start(self): + global started + self.started = started = True + + def finish(self) + global started + self.started = started = False + def prepare(self): self.setupInitialLogging() self.setupLocale() Index: run.py =================================================================== --- run.py (revision 39858) +++ run.py (working copy) @@ -15,11 +15,7 @@ def run(): """ Start a Zope instance """ import Zope2.Startup - starter = Zope2.Startup.get_starter() - opts = _setconfig() - starter.setConfiguration(opts.configroot) - starter.prepare() - starter.run() + Zope2.Startup.start_zope(_setconfig().configroot, None) def configure(configfile): """ Provide an API which allows scripts like zopectl to configure