[Zope-Checkins] CVS: Zope/inst - custom_zodb.py.in:1.1.2.4 zctl.in:1.1.2.7
Chris McDonough
chrism@zope.com
Tue, 10 Sep 2002 00:16:00 -0400
Update of /cvs-repository/Zope/inst
In directory cvs.zope.org:/tmp/cvs-serv11896/inst
Modified Files:
Tag: chrism-install-branch
custom_zodb.py.in zctl.in
Log Message:
Directives are now stored in a singleton registry. The defaults are read from the 'directives.csv' file in the Controller package and registered dynamically. As a result, the 'makedirectives.py' script was removed as it is no longer necessary.
The option to get a configuration from XML-RPC was removed in favor of
obtaining a configuration file over HTTP. The command-line options
to both zope.py and zctl were changed accordingly.
=== Zope/inst/custom_zodb.py.in 1.1.2.3 => 1.1.2.4 ===
--- Zope/inst/custom_zodb.py.in:1.1.2.3 Sat Sep 7 13:11:16 2002
+++ Zope/inst/custom_zodb.py.in Tue Sep 10 00:15:59 2002
@@ -22,62 +22,57 @@
import warnings, traceback
import sys, os
import zLOG
-from Controller import Directives
+from Controller.Directives import DirectiveRegistry as reg
-def get(directive):
- return directive.value
+CLIENT_HOME = reg['client_home']
-INSTANCE_HOME = get(Directives.instance_home)
-
-if get(Directives.use_zeo_server):
+if reg['use_zeo_server']:
port = None
path = None
- hostname = get(Directives.zeo_storage_server_hostname)
- port_or_path = get(Directives.zeo_storage_server_path_or_port)
- storage_name = get(Directives.zeo_storage_server_storagename) or '1'
- cache_size = get(Directives.zeo_client_cache_size) or 200000000
- debug = get(Directives.zeo_client_debug) or 0
- cache_dir = (get(Directives.zeo_client_cache_directory) or
- os.path.join(INSTANCE_HOME, 'var'))
- max_disconn = get(Directives.zeo_client_max_disconnect_poll) or 300
- min_disconn = get(Directives.zeo_client_min_disconnect_poll) or 5
- wait = (get(Directives.zeo_client_wait_for_server_on_startup)
- or 0)
- client_name = get(Directives.zeo_client_name) or ''
+ hostname = reg['zeo_storage_server_name']
+ port_or_path = reg['Directives.zeo_storage_server_port']
+ storage_name = reg['zeo_storage_server_storagename'] or '1'
+ cache_size = reg['zeo_client_cache_size'] or 200000000
+ debug = reg['zeo_client_debug'] or 0
+ cache_dir = reg['zeo_client_cache_directory'] or CLIENT_HOME
+ max_disconn = reg['zeo_client_max_disconnect_poll'] or 300
+ min_disconn = reg['zeo_client_min_disconnect_poll'] or 5
+ wait = reg['zeo_client_wait_for_server_on_startup'] or 0
+ client_name = reg['zeo_client_name'] or ''
try:
port = int(port_or_path)
conn = (hostname, port)
except:
- conn = port_or_path
+ conn = path
try:
import ZServer
import ZEO.ClientStorage
# we left out "name" here but it's ok as it's just the
# "pretty name" shown in the control panel
Storage = ZEO.ClientStorage.ClientStorage(
- addr=conn, storage=storage_name, cache_size=cache_size,
- client=client_name, var=cache_dir,
+ connection=conn, storage=storage_name, cache_size=cache_size,
+ client=client_name, debug=debug, var=cache_dir,
min_disconnect_poll=min_disconn, max_disconnect_poll=max_disconn,
- wait=wait)
+ wait_for_server_on_startup=wait)
except:
- zLOG.LOG('custom_zodb', 100, 'Could not use ZEO!', error=sys.exc_info())
+ zLOG.LOG('custom_zodb', 100, 'Could not use ZEO!', err=sys.exc_info())
traceback.print_exc()
err = ('Could not successfully start Zope due to ZEO configuration '
'error! Clues exist in the traceback printed above. Check '
'your zope.conf file for a misconfiguration.')
warnings.warn(err)
# exit the process instead of silently using a FileStorage
- sys.exit(127)
+ sys.exit(255)
else:
import ZODB.FileStorage
- default = os.path.join(INSTANCE_HOME, 'var')
- filename = get(Directives.zodb_filestorage_filepath) or default
+ default = os.path.join(CLIENT_HOME, 'Data.fs')
+ filename = reg['zodb_filestorage_filepath'] or default
Storage = ZODB.FileStorage.FileStorage(filename)
# use environment to try to get cache size and pool size
# parameters
-pool_size = get(Directives.zodb_db_pool_size) or 7
-cache_size = get(Directives.zodb_db_cache_size) or 5000
+pool_size = reg['zodb_db_pool_size'] or 7
+cache_size = reg['zodb_db_cache_size'] or 5000
DB=ZODB.DB(Storage, pool_size=pool_size, cache_size=cache_size)
=== Zope/inst/zctl.in 1.1.2.6 => 1.1.2.7 ===
--- Zope/inst/zctl.in:1.1.2.6 Sat Sep 7 13:17:34 2002
+++ Zope/inst/zctl.in Tue Sep 10 00:15:59 2002
@@ -33,8 +33,7 @@
sys.path.insert(0, SOFTWARE_HOME)
sys.path = filter(None, sys.path)
-from Controller.Main import parse_config_file, get_xmlrpc_config, \
- Configuration, lock_file
+from Controller.Directives import DirectiveRegistry
from Controller import TextBlockFormatter
USAGE = """\
@@ -42,17 +41,20 @@
zctl: Zope appserver controller
Usage:
- zctl [-h | --help] [--config-file=filepath] [--config-url=url] [commands*]
+ zctl [-h | --help] [--config-location=filepath or url]
Options:
- -h or --help Print this message. Not compatible with the 'start'
- or 'restart' command.
-
- --config-file Use an alternate configuration file. Default: 'zope.conf'
+ -h or --help Print this message. Not compatible with the 'start'
+ or 'restart' command.
+
+ --config-location Use an alternate configuration from a local file.
+ or a URL. Default: 'zope.conf'.
- --config-url Obtain configuration from XML-RPC via this URL. If
- this option is provided, the --config-file argument
- is ignored.
+ If a URL is specified, it must begin with
+ 'http://'.
+
+ File example: '/home/chrism/zope.conf'
+ URL example: 'http://www.zope.org/zope.conf'
Commands:
help [<command>]
@@ -93,6 +95,7 @@
All options are passed to the zope.py command line.
"""
if self._getDirective('use_zeo_server'):
+
# Is the ZEO server up? start it if not
zeo_host, zeo_port, zeo_socket = self._getZEOConfig()
if not self._checkService(zeo_host, zeo_port, zeo_socket):
@@ -457,7 +460,6 @@
self._report( normalizeDocstring( getattr( self, method_name ) ) )
def _setConfig( self, config ):
- config.activate()
self._config = config
def _getSoftwareHome(self):
@@ -475,9 +477,6 @@
def _getDirective(self, name):
return self._config.get(name)
- def _setConfigPath( self, path ):
- self._config_path = path
-
def _setCommandLineOpts( self, l ):
self._cmdline = l
@@ -564,7 +563,7 @@
def _showConfigPath( self ):
self._report()
- self._report('Configuration Path: %s' % self._config_path)
+ self._report('Configuration Path: %s' % self._config.getLocation())
def _showDirectives( self ):
self._report()
@@ -737,9 +736,8 @@
return [a for a in meta if a.startswith(text) ]
do_start = _MAKEDO( 'start' )
- do_start = _MAKEDO( 'start' )
- do_zeo_start = _MAKEDO( 'zeo_start' )
- do_zeo_stop = _MAKEDO( 'zeo_stop' )
+ do_start_zeo = _MAKEDO( 'start_zeo' )
+ do_stop_zeo = _MAKEDO( 'stop_zeo' )
do_restart = _MAKEDO( 'restart' )
do_logopenclose = _MAKEDO( 'logopenclose' )
do_stop = _MAKEDO( 'stop' )
@@ -757,10 +755,9 @@
self._report( USAGE )
def main( self ):
- filename = 'zope.conf'
- url = None
+ config_location = 'zope.conf'
try:
- longopts = ['help', 'config-file=', 'config-url=']
+ longopts = ['help', 'config-location=']
o, a = getopt.getopt( sys.argv[1:], 'h', longopts)
except getopt.GetoptError, v:
print v
@@ -771,16 +768,11 @@
if k in ('-h', '--help'):
self.usage()
sys.exit(0)
- elif k == '--config-file':
- filename = v
- elif k == '--config-url':
- url = v
- if url:
- self._engine._setConfig(Configuration(get_xmlrpc_config(url)))
- self._engine._setConfigPath(url)
- else:
- self._engine._setConfig(Configuration(parse_config_file(filename)))
- self._engine._setConfigPath(filename)
+ elif k == '--config-location':
+ config_location = v
+ reg = DirectiveRegistry
+ reg.reconfigure(config_location)
+ self._engine._setConfig(reg)
self._engine._setCommandLineOpts(o)
if a:
self.cmdqueue.append( ' '.join( a ) )