[Zope-Checkins] CVS: Zope/inst - register_software.py:1.1.2.2

Matt Behrens matt@zigg.com
Wed, 22 May 2002 21:19:37 -0400


Update of /cvs-repository/Zope/inst
In directory cvs.zope.org:/tmp/cvs-serv23389/inst

Modified Files:
      Tag: zigg_unix-install-control-config-branch
	register_software.py 
Log Message:
Further progress on this branch.

'zope create', to create an instance, works now, although the
instance is currently rather bare :-)



=== Zope/inst/register_software.py 1.1.2.1 => 1.1.2.2 ===
 import ConfigParser, os, sys
 
+def registerAsDefault(system_conf, software_name):
+    if not system_conf.has_section('defaults'):
+        system_conf.add_section('defaults')
+    system_conf.set('defaults', 'software', software_name)
+
 config_dir = sys.argv[1]
 software_name = sys.argv[2]
 software_home = sys.argv[3]
@@ -26,13 +31,22 @@
 system_conf = ConfigParser.ConfigParser()
 system_conf.read(system_conf_name)
 
-if not system_conf.has_section('SoftwareHomes'):
-    system_conf.add_section('SoftwareHomes')
-system_conf.set('SoftwareHomes', software_name, software_home)
+if not system_conf.has_section('software_homes'):
+    system_conf.add_section('software_homes')
+system_conf.set('software_homes', software_name, software_home)
+
 if register_default:
-    if not system_conf.has_section('Defaults'):
-        system_conf.add_section('Defaults')
-    system_conf.set('Defaults', 'Instance', software_name)
+    # Unconditionally register as default
+    registerAsDefault(system_conf, software_name)
+else:
+    # Only register if no default exists
+    if not system_conf.has_option('defaults', 'software'):
+	registerAsDefault(system_conf, software_name)
+
+# Also register a default instance name if it does not exist
+if not system_conf.has_option('defaults', 'instance'):
+    system_conf.set('defaults', 'instance', 'default')
+
 f = open(system_conf_name, 'w')
 system_conf.write(f)
 f.close()