[Zope-Checkins] CVS: Zope/lib/python/Controller - MetaDirective.py:1.1.2.1 ZopeCtl.py:1.1.2.2 directives.csv:1.1.2.3 directives.py:1.1.2.2 makedirectives.py:1.1.2.2
Chris McDonough
chrism@zope.com
Thu, 29 Aug 2002 01:22:10 -0400
Update of /cvs-repository/Zope/lib/python/Controller
In directory cvs.zope.org:/tmp/cvs-serv27577/lib/python/Controller
Modified Files:
Tag: chrism-install-branch
ZopeCtl.py directives.csv directives.py makedirectives.py
Added Files:
Tag: chrism-install-branch
MetaDirective.py
Log Message:
- Renamed zopectl to zctl ('zope<tab> always finds zope.conf too!)
- Created a new 'make instance' target in Makefile for running from
a "build" directory directly.
- Updated some directives and refactored directive code.
- zctl show now shows directives instead of command-line switches
and envvars in output.
=== Added File Zope/lib/python/Controller/MetaDirective.py ===
def stringHandler(s, name, influences, type):
return {influences:s}
pathHandler = stringHandler
def onoffHandler(s, name, influences, type):
if type =='env':
if s == 'on':
return {influences:'1'}
else:
return {influences:'0'}
else:
if s == 'on':
return {influences:''} # nonvalued switch
else:
return {}
def intHandler(s, name, influences, type):
try:
int(s)
except:
raise ValueError, '%s is not a valid integer value for %s' % (s,name)
return {influences:s}
def stringListHandler(s, name, influences, type):
l = s.split()
out = []
i = 0
d = {}
if type == 'env':
raise ValueError, ('stringListHandler not equipped to handle '
'environment settings for %s' % name)
for item in l:
# lame, but we use spaces to pad the keys in order to
# handle multiple of the same command-line switch directives
padding = ' ' * i
padded = '%s%s' % (padding, influences)
d[padded] = item
i = i + 1
return d
dispatch = {
'path':pathHandler,
'onoff':onoffHandler,
'string':stringHandler,
'int':intHandler,
'stringlist':stringListHandler,
}
_marker = []
class Directive:
def __init__(self, value=_marker):
if value is not _marker:
self.value = value
def output(self):
if self.value is None:
return None
return dispatch[self.valtype](
self.value,
self.getName(),
self.influences,
self.type,
)
def getName(self):
return self.__class__.__name__
class EnvironmentDirective(Directive):
type = 'env'
def acceptVisit(self, visitor):
visitor.visitEnvironmentDirective(self)
class CommandLineDirective(Directive):
type = 'cmd'
def acceptVisit(self, visitor):
visitor.visitCommandLineDirective(self)
=== Zope/lib/python/Controller/ZopeCtl.py 1.1.2.1 => 1.1.2.2 ===
--- Zope/lib/python/Controller/ZopeCtl.py:1.1.2.1 Mon Aug 26 02:22:37 2002
+++ Zope/lib/python/Controller/ZopeCtl.py Thu Aug 29 01:22:09 2002
@@ -249,16 +249,23 @@
def show( self, what=None ):
"""
Print a message showing all or part of the current
- configuration.
+ Zope configuration. 'show' alone implies 'show config'.
Parts include:
- - python
- - config-file
- - config
- - env
- - opts
- - command-line
+ - config Combo of 'directives', 'python', 'config-file'
+
+ - directives All active directives
+
+ - python Python version and path info
+
+ - config-file Path to config file
+
+ - env Environment as result of directives
+
+ - opts Command-line options as a result of directives
+
+ - command-line Full command-line to pass to z2.py
"""
if type( what ) is type( '' ):
what = what.split( ' ' )
@@ -270,6 +277,7 @@
, 'env'
, 'opts'
, 'command-line'
+ , 'directives'
)
unknown = []
@@ -282,12 +290,10 @@
if not whatsit:
whatsit[ 'python' ] = 1
whatsit[ 'config' ] = 1
- whatsit[ 'command-line' ] = 1
if whatsit.get( 'config' ):
whatsit[ 'config-file' ] = 1
- whatsit[ 'env' ] = 1
- whatsit[ 'opts' ] = 1
+ whatsit[ 'directives' ] = 1
self._showHeader()
@@ -297,6 +303,7 @@
if ( whatsit.get( 'env' )
or whatsit.get( 'opts' )
or whatsit.get( 'command-line' )
+ or whatsit.get( 'directives') == 1
):
self.configure(1)
@@ -315,6 +322,9 @@
if whatsit.get( 'command-line' ):
self._showCommandLine()
+ if whatsit.get( 'directives' ):
+ self._showConfiguredDirectives()
+
self._showFooter()
def run( self, arg ):
@@ -503,6 +513,18 @@
self._report( '%-22s : %s' % ( 'z2.py command line'
, self._buildCommandLine() ) )
self._report()
+
+ def _showConfiguredDirectives( self ):
+ self._report()
+ directives = self.config.getConfiguredDirectives()
+ self._report( 'Configured Directives:' )
+ self._report()
+ items = directives.items()
+ items.sort()
+ for name, directive in items:
+ self._report( ' %-26s : %s' % ( name, directive.value ) )
+ self._report()
+
def _showFooter( self ):
self._report()
@@ -511,6 +533,9 @@
def __init__(self):
self.commands = {}
self.environs = {}
+ self.directives = {}
+ from directives import __all__ as all_directives
+ self.all_directives = all_directives
me = sys.modules[__name__].__file__
# This assumes this module lives in the Controller package
# beneath lib/python
@@ -518,24 +543,31 @@
zope_home = os.sep.join(software_home.split(os.sep)[:-2])
instance_home = os.getcwd()
client_home = os.path.join(instance_home, 'var')
- event_log_filename = os.path.join(instance_home, 'var', 'event.log')
- self.directives = {
- 'software_home':directives.software_home(software_home),
- 'zope_home':directives.software_home(zope_home),
- 'instance_home':directives.instance_home(instance_home),
- 'client_home':directives.client_home(client_home),
- 'http_server_ports':directives.http_server_ports('8080'),
- 'ftp_server_ports':directives.ftp_server_ports('8021'),
- 'webdav_source_server_ports':
- directives.webdav_source_server_ports('9800'),
- 'event_log_filename':
- directives.event_log_filename(event_log_filename),
- }
-
+ # set up default directives
+ default_directives = (
+ directives.software_home(software_home),
+ directives.zope_home(zope_home),
+ directives.instance_home(instance_home),
+ directives.client_home(client_home),
+ directives.http_server_ports('8080'),
+ directives.ftp_server_ports('8021'),
+ directives.webdav_source_server_ports('9800'),
+ directives.debug_mode('on'),
+ directives.event_log_filename(''),
+ )
+ for directive in default_directives:
+ self.directives[directive.__class__.__name__] = directive
+
def activateDirectives(self, config_file):
self.parseConfigFile(config_file)
self.visitDirectives()
self.activateEnvironment()
+
+ def getConfiguredDirectives(self):
+ return self.directives
+
+ def getAllDirectiveNames(self):
+ return self.all_directives
def visitDirectives(self):
for directive in self.directives.values():
=== Zope/lib/python/Controller/directives.csv 1.1.2.2 => 1.1.2.3 ===
--- Zope/lib/python/Controller/directives.csv:1.1.2.2 Mon Aug 26 18:46:03 2002
+++ Zope/lib/python/Controller/directives.csv Thu Aug 29 01:22:09 2002
@@ -1,4 +1,3 @@
-CATEGORY DIRECTIVE DESC TYPE VALTYPE INFLUENCES META_DEFAULT DEFAULT EXAMPLE
general zope_home The 'top-level' Zope software directory (home of the Zserver directory, the doc directory, the utilities directory, etc.) env path ZOPE_HOME none (required) None /home/chrism/software/Trunk
general instance_home The path to the data files, local product files, import directory, and Extensions directory used by Zope. env path INSTANCE_HOME none (required) None /home/chrism/projects/sessions
general software_home The path to the majority of the Python software files used by Zope. One software_home can support many instance_homes. env path SOFTWARE_HOME none (required) None /home/chrism/software/Trunk/lib/python
@@ -15,7 +14,7 @@
log access_log_filename The file path of the Zope 'access' log (z2.log) which is written in the combined logfile format. The access log will be printed to standard output if the 'zserver_read_only' directive is set to 'on', regardless of this setting. cmd string -I INSTANCE_HOME/var/z2.log None /home/chrism/projects/sessions/z2.log
log access_syslog_path Same as event_syslog_path, only for the "access" log data (z2.log data). env path ZSYSLOG_ACCESS unset None /dev/log
log access_syslog_server Same as event_syslog_path, only for the 'access' data (z2.log data). env string ZSYSLOG_ACCESS_SERVER unset None syslog.example.com:514
-log event_log_file Path to the Zope event log for debugging information. env path EVENT_LOG_FILE unset None /home/chrism/projects/var/event.log
+log event_log_filename Path to the Zope event log for debugging information. env path EVENT_LOG_FILE unset None /home/chrism/projects/var/event.log
log event_log_severity Filter events that can be written to the event log by priority. A higher priority means fewer events will be written. Choose one of (300, 200, 100, 0, -100, -200, or -300). Descriptions of the integer levels are as follows: 300=PANIC, 200=ERROR, 100=WARNING, 0=INFO, -100=BLATHER, -200=DEBUG, -300=TRACE). env string EVENT_LOG_SEVERITY 0 None 100
log event_syslog_facility The facility used when the event log is being written to syslog (when 'event_syslog_path' or 'event_syslog_server' is set). env string ZSYSLOG_FACILITY user None local7
log event_syslog_path Setting this directive will cause Zope to write the event log to syslog on the named UNIX domain socket on the local host. This only works on UNIX. It is overridden by specifying 'event_syslog_server'. env path ZSYSLOG unset None /dev/log
=== Zope/lib/python/Controller/directives.py 1.1.2.1 => 1.1.2.2 ===
--- Zope/lib/python/Controller/directives.py:1.1.2.1 Mon Aug 26 02:22:37 2002
+++ Zope/lib/python/Controller/directives.py Thu Aug 29 01:22:09 2002
@@ -1,85 +1,16 @@
-def stringHandler(s, name, influences, type):
- return {influences:s}
+from MetaDirective import EnvironmentDirective, CommandLineDirective
-pathHandler = stringHandler
-
-def onoffHandler(s, name, influences, type):
- if type =='env':
- if s == 'on':
- return {influences:'1'}
- else:
- return {influences:'0'}
- else:
- if s == 'on':
- return {influences:''} # nonvalued switch
- else:
- return {}
-
-def intHandler(s, name, influences, type):
- try:
- int(s)
- except:
- raise ValueError, '%s is not a valid integer value for %s' % (s,name)
- return {influences:s}
-
-def stringListHandler(s, name, influences, type):
- l = s.split()
- out = []
- i = 0
- d = {}
- if type == 'env':
- raise ValueError, ('stringListHandler not equipped to handle '
- 'environment settings for %s' % name)
- for item in l:
- # lame, but we use spaces to pad the keys in order to
- # handle multiple of the same command-line switch directives
- padding = ' ' * i
- padded = '%s%s' % (padding, influences)
- d[padded] = item
- i = i + 1
- return d
-
-dispatch = {
- 'path':pathHandler,
- 'onoff':onoffHandler,
- 'string':stringHandler,
- 'int':intHandler,
- 'stringlist':stringListHandler,
- }
-
-
-_marker = []
-
-class Directive:
- def __init__(self, value=_marker):
- if value is not _marker:
- self.value = value
-
- def output(self):
- if self.value is None:
- return None
- return dispatch[self.valtype](
- self.value,
- self.getName(),
- self.influences,
- self.type,
- )
-
- def getName(self):
- return self.__class__.__name__
-
-class EnvironmentDirective(Directive):
- type = 'env'
- def acceptVisit(self, visitor):
- visitor.visitEnvironmentDirective(self)
-
-class CommandLineDirective(Directive):
- type = 'cmd'
- def acceptVisit(self, visitor):
- visitor.visitCommandLineDirective(self)
+class zope_home(EnvironmentDirective):
+ desc = 'The \'top-level\' Zope software directory (home of the Zserver directory, the doc directory, the utilities directory, etc.)'
+ category = 'general'
+ valtype = 'path'
+ influences = 'ZOPE_HOME'
+ value = None
+ meta_default = 'none (required)'
+ example = '/home/chrism/software/Trunk'
class instance_home(EnvironmentDirective):
- desc = 'The path to the data files, local product files, import directory, and Extensions directory used by Zope. One software_home can support many instance_homes.'
+ desc = 'The path to the data files, local product files, import directory, and Extensions directory used by Zope.'
category = 'general'
valtype = 'path'
influences = 'INSTANCE_HOME'
@@ -88,7 +19,7 @@
example = '/home/chrism/projects/sessions'
class software_home(EnvironmentDirective):
- desc = 'The path to the majority of the Python software files used by Zope.'
+ desc = 'The path to the majority of the Python software files used by Zope. One software_home can support many instance_homes.'
category = 'general'
valtype = 'path'
influences = 'SOFTWARE_HOME'
@@ -96,15 +27,6 @@
meta_default = 'none (required)'
example = '/home/chrism/software/Trunk/lib/python'
-class zope_home(EnvironmentDirective):
- desc = 'The \'top-level\' Zope software directory (home of the ZServer directory, the doc directory, the utilities directory, etc.)'
- category = 'general'
- valtype = 'path'
- influences = 'ZOPE_HOME'
- value = None
- meta_default = 'none (required)'
- example = '/home/chrism/software/Trunk'
-
class client_home(EnvironmentDirective):
desc = 'The directory in which a running Zope\'s process identifier files are placed.'
category = 'general'
@@ -121,7 +43,7 @@
influences = '-D'
value = None
meta_default = 'on'
- example = ''
+ example = 'on'
class effective_user(CommandLineDirective):
desc = 'If you intend to run Zope as the \"root\" user, you must supply this directive with an effective username or userid number to which Zope will \'suid\' after the server ports are bound. This directive only works under UNIX and if Zope is started as the root user.'
@@ -139,7 +61,7 @@
influences = 'FORCE_PRODUCT_LOAD'
value = None
meta_default = 'unset'
- example = ''
+ example = 'on'
class locale(CommandLineDirective):
desc = 'Enable locale (internationalization) support by supplying a locale name to be used. See your operating system documentation for locale information specific to your system. If your Python module does not support the locale module, or if the requested locale is not supported by your system, an error will be raised and Zope will not start.'
@@ -175,7 +97,7 @@
influences = '-Z'
value = None
meta_default = 'on'
- example = ''
+ example = 'on'
class zserver_read_only_mode(CommandLineDirective):
desc = 'If this directive is set to \'on\', it will cause Zope to inhibit the creation of log files and pid files. Access and event log files will be presented on standard output. Setting this directive \'on\' causes pcgi, fastcgi, and daemon-related directives to have no effect.'
@@ -184,7 +106,7 @@
influences = '-r'
value = None
meta_default = 'off'
- example = ''
+ example = 'on'
class acccess_syslog_facility(EnvironmentDirective):
desc = 'Same as \'event_syslog_facility\', only for the \"access\" log data (z2.log data).'
@@ -220,15 +142,15 @@
influences = 'ZSYSLOG_ACCESS_SERVER'
value = None
meta_default = 'unset'
- example = 'Syslog.example.com:514'
+ example = 'syslog.example.com:514'
class event_log_filename(EnvironmentDirective):
desc = 'Path to the Zope event log for debugging information.'
category = 'log'
valtype = 'path'
influences = 'EVENT_LOG_FILE'
- value = ''
- meta_default = 'console'
+ value = None
+ meta_default = 'unset'
example = '/home/chrism/projects/var/event.log'
class event_log_severity(EnvironmentDirective):
@@ -298,7 +220,7 @@
desc = 'Causing this directive to point to a file on the filesystem will cause Zope\'s profiling capabilities to be enabled. For more information, see the Debug -> Profiling tab of the Control_Panel.'
category = 'misc'
valtype = 'path'
- influences = 'PROFILE_PUBLISHER unset'
+ influences = 'PROFILE_PUBLISHER'
value = None
meta_default = 'unset'
example = '/home/chrism/projects/sessions/var/profile/dat'
@@ -355,7 +277,7 @@
influences = '-C'
value = None
meta_default = 'off'
- example = ''
+ example = 'on'
class ftp_server_ports(CommandLineDirective):
desc = 'A space-separated list of TCP port numbers on which Zope will listen for FTP requests.'
@@ -418,7 +340,7 @@
influences = 'ZOPE_DTML_REQUEST_AUTOQUOTE'
value = None
meta_default = 'on'
- example = ''
+ example = 'on'
class perform_authentication_checking(EnvironmentDirective):
desc = 'Set this directive to \'off\' to cause Zope to allow unauthenticated access to all resources. DANGEROUS.'
@@ -427,7 +349,7 @@
influences = 'ZSP_AUTHENTICATED_SKIP'
value = None
meta_default = 'on'
- example = ''
+ example = 'on'
class perform_ownership_checking(EnvironmentDirective):
desc = 'Set this directive to \'off\' to cause Zope to ignore ownership checking when attempting to execute \"through the web\" code. By default, this directive is on in order to prevent \'trojan horse\' security problems whereby a user with less privilege can cause a user with more privilege to execute dangerous code.'
@@ -436,7 +358,7 @@
influences = 'ZSP_OWNEROUS_SKIP'
value = None
meta_default = 'on'
- example = ''
+ example = 'on'
class security_policy_implementation(EnvironmentDirective):
desc = 'Set this directive to \'PYTHON\' to use a pure-Python implementation of Zope\'s default security policy. The default value for this directive is \'C\". Setting it to PYTHON causes Zope to run more slowly, but it can be helpful when attempting to debug security-related application failures.'
@@ -490,7 +412,7 @@
influences = 'SUPPRESS_ACCESRULE'
value = None
meta_default = 'off'
- example = ''
+ example = 'on'
class suppress_all_site_roots(EnvironmentDirective):
desc = 'If this directive is set to on, no site roots in your Zope site will be effective. This is useful if you \"lock yourself out\" of a particular part of your site by setting an improper site root.'
@@ -499,7 +421,7 @@
influences = 'SUPPRESS_SITEROOT'
value = None
meta_default = 'off'
- example = ''
+ example = 'on'
class database_quota_size(EnvironmentDirective):
desc = 'Set this directive to an integer in bytes in order to place a hard limit on the size which the default FileStorage-backed Zope database can grow. Additions to the database will not be permitted once this filesize is exceeded.'
@@ -517,7 +439,7 @@
influences = 'ZOPE_READ_ONLY'
value = None
meta_default = 'off'
- example = ''
+ example = 'on'
class zeo_client_name(EnvironmentDirective):
desc = 'Provide a string value to uniquely identify the local cache files created if this Zope is a ZEO client. Setting this directive implies setting \'inhibit_product_installation\' to \'on\' if \'inhibit_product_installation\' is left unset.'
@@ -528,3 +450,4 @@
meta_default = 'unset'
example = 'zeo1'
+__all__ = ['zope_home', 'instance_home', 'software_home', 'client_home', 'debug_mode', 'effective_user', 'inhibit_product_installation', 'locale', 'number_of_threads', 'python_check_interval', 'use_daemon_process', 'zserver_read_only_mode', 'acccess_syslog_facility', 'access_log_filename', 'access_syslog_path', 'access_syslog_server', 'event_log_file', 'event_log_severity', 'event_syslog_facility', 'event_syslog_path', 'event_syslog_server', 'trace_log_filename', 'default_structured_text_header_level', 'maximum_security_manager_stack_size', 'publisher_profile_file', 'webdav_source_user_agents', 'dns_server_address', 'ip_address', 'default_http_realm', 'fastcgi_resource_path_or_port', 'force_http_connection_close', 'ftp_server_ports', 'http_server_ports', 'icp_server_ports', 'monitor_server_ports', 'pcgi_resource_path', 'webdav_source_server_ports', 'automatically_quote_dtml_request_data', 'perform_authentication_checking', 'perform_ownership_checking', 'security_policy_impl!
ementation', 'maximum_number_of_session_objects', 'session_add_notify_script_path', 'session_delete_notify_script_path', 'session_timeout_minutes', 'suppress_all_access_rules', 'suppress_all_site_roots', 'database_quota_size', 'read_only_database', 'zeo_client_name']
=== Zope/lib/python/Controller/makedirectives.py 1.1.2.1 => 1.1.2.2 ===
--- Zope/lib/python/Controller/makedirectives.py:1.1.2.1 Mon Aug 26 02:22:37 2002
+++ Zope/lib/python/Controller/makedirectives.py Thu Aug 29 01:22:09 2002
@@ -1,8 +1,8 @@
-header_text = ''
def main():
f = open('directives.csv', 'r')
- print header_text
+ all = []
+ print "from MetaDirective import EnvironmentDirective, CommandLineDirective"
while 1:
line = f.readline()
if not line:
@@ -30,6 +30,9 @@
print " value = %s" % default
print " meta_default = '%s'" % meta_default
print " example = '%s'" % example
+ all.append(name)
+ print
+ print '__all__ = %s' % repr(all)
if __name__=='__main__':
main()