[Zope-CVS] CVS: Zope - zope.py:1.1.2.1

Jens Vagelpohl jens@zope.com
Mon, 2 Sep 2002 21:27:36 -0400


chris,

i hate to say it, but the problem with realpath is still there :(

jens


On Monday, Sep 2, 2002, at 03:35 US/Eastern, Chris McDonough wrote:

> Update of /cvs-repository/Zope
> In directory cvs.zope.org:/tmp/cvs-serv17315
>
> Added Files:
>       Tag: chrism-install-branch
> 	zope.py
> Log Message:
> Overhaul of installer branch.
>
> z2.py is no longer necessary (nor used in the default config).
> In prior iterations of the installer branch, the "controller" process
> (zctl) "front-ended" for z2.py, translating environment variables and
> command-line options as necessary to pass in to z2.py.
>
> In this iteration, a new file named "zope.py" is responsible for  
> starting
> the Zope process.  It reads configuration directives directly and has
> the capability to obtain a configuration from a file or via XML-RPC.
> z2.py still exists in the branch, but it's unused.
>
> The zope.py file can be used to start Zope, but a nicer front-end
> for it is "zctl", which is a heavily-modified offshoot of Tres'
> "zopectl".  The zctl module is now generalized enough that it
> *might* be able to run on Windows (I haven't tested it, though).
>
> zctl is still a standalone process.  This is to allow for the fact that
> Windows doesn't have os.fork (or zctl would have just imported zope.py
> and forked).
>
> In order to maintain cross-platform capability, the "logtail" option
> of zctl was removed.  We should create a Python "tail" function
> to get around this.
>
> Niceties: zctl is able to tell if its Zope is already running (so you
> cant inadvertently start it twice).  The Z2.pid file is cleaned up
> when Zope exits, also.
>
> A small bug in FindHomes.py was also fixed (dont add SOFTWARE_HOME to
> sys.path if it's already in there).  Additionally, zdaemon was modified
> so that if a child Zope process exits with error code 255, the daemon
> process does not restart it (not strictly necessary, but nice to have).
>
>
> === Added File Zope/zope.py ===
> ####################################################################### 
> #######
> #
> # Copyright (c) 2001 Zope Corporation and Contributors. All Rights  
> Reserved.
> #
> # This software is subject to the provisions of the Zope Public  
> License,
> # Version 2.0 (ZPL).  A copy of the ZPL should accompany this  
> distribution.
> # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
> # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
> # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND  
> FITNESS
> # FOR A PARTICULAR PURPOSE
> #
> ####################################################################### 
> #######
> """This is a replacement for z2.py which uses a config file or
> a config retrieved via XML-RPC directly.
>
> Do not change this file unless you know what you're doing. ;-)
> """
>
> import os, sys, getopt, warnings, traceback
>
> # assume that this file is sys.argv[0], and that it lives in ZOPE_HOME  
> in
> # order to set sys.path appropriately so we can get at the Controller
> # package.
> HERE = os.path.split(os.path.abspath(os.path.normpath(sys.argv[0])))[0]
> SOFTWARE_HOME = os.path.join(HERE, 'lib', 'python')
>
> # an importer may have already set SOFTWARE_HOME
> if SOFTWARE_HOME not in sys.path:
>     sys.path.insert(0, SOFTWARE_HOME)
>
> from Controller import Main
>
> def check_python_version():
>     # check for Python version
>     python_version = sys.version.split()[0]
>     if python_version < '2.1':
>         raise 'Invalid python version', python_version
>     if python_version[:3] == '2.1':
>         if python_version[4:5] < '3':
>             err = ('You are running Python version %s.  This Python  
> version '
>                    'has known bugs that may cause Zope to run  
> improperly. '
>                    'Consider upgrading to a Python in the 2.1 series '
>                    'with at least version number 2.1.3.  (Note that  
> Zope does '
>                    'not yet run under any Python 2.2 version).' %
>                    python_version)
>             warnings.warn(err)
>     if python_version[:3] == '2.2':
>         err = ('You are running Python version %s.  This Python  
> version '
>                'has not yet been tested with Zope and you may  
> experience '
>                'operational problems as a result.  Consider using '
>                'Python 2.1.3 instead.' % python_version)
>         warnings.warn(err)
>
> def usage():
>     print """
> zope.py [--config-file=filename] [--config-url=url]
>
> zope.py starts a Zope instance.
>
> If no config- options are passed, an attempt is made to obtain  
> configuration
> info from a file in the current working directory named 'zope.conf'.   
> If both
> a configuration url and a configuration filename are specified, the
> configuration url is used and the filename is ignored.  The url should  
> point
> to a valid XML-RPC server methodname and the XML-RPC server method  
> should
> return a dictionary of configuration directives in the same format as
> a configuration file.
> """ % {'me':sys.argv[0]}
>
> if __name__ == '__main__':
>     check_python_version()
>     filename = 'zope.conf'
>     url = None
>     longopts = [ "help", "config-file=", "config-url=" ]
>     try:
>         opts, args = getopt.getopt(sys.argv[1:], "h", longopts)
>     except getopt.GetoptError, v:
>         print v
>         usage()
>         sys.exit(127)
>     for k, v in opts:
>         if k in ('-h', '--help'):
>             usage()
>             sys.exit(0)
>         if k == '--config-file':
>             filename = v
>         if k == '--config-url':
>             url = v
>     if url:
>         local_config = Main.get_xmlrpc_config(url)
>     else:
>         local_config = Main.parse_config_file(filename)
>     try:
>         config = Main.Configuration(local_config)
>         config.activate()
>         Main.start_zope(config)
>     except SystemExit:
>         pass
>     except:
>         try:
>             import zLOG
>             zLOG.LOG("Zope Initialization", zLOG.PANIC, "Startup  
> exception",
>                      error=sys.exc_info())
>         except:
>             pass
>         traceback.print_exc()
>         # tell zdaemon not to restart us by setting 255 exit code
>         sys.exit(255)
>
>
>
>
>
>
>
> _______________________________________________
> Zope-CVS maillist  -  Zope-CVS@zope.org
> http://lists.zope.org/mailman/listinfo/zope-cvs
>
> Zope CVS instructions: http://dev.zope.org/CVS