[Zope-Checkins] CVS: ZODB3/zdaemon - zdoptions.py:1.22

Fred L. Drake, Jr. fred@zope.com
Thu, 20 Feb 2003 10:36:54 -0500


Update of /cvs-repository/ZODB3/zdaemon
In directory cvs.zope.org:/tmp/cvs-serv12620

Modified Files:
	zdoptions.py 
Log Message:
Add support for a -X option that feeds override information to the
ZConfig support.  This allows:

  python foo.py -C myapp.conf -X setting=value

to specify an alternate value for the key "setting" in the myapp.conf
configuration file, providing a value if one is not already specified.


=== ZODB3/zdaemon/zdoptions.py 1.21 => 1.22 ===
--- ZODB3/zdaemon/zdoptions.py:1.21	Fri Feb 14 07:10:35 2003
+++ ZODB3/zdaemon/zdoptions.py	Thu Feb 20 10:36:53 2003
@@ -48,8 +48,10 @@
         self.default_map = {}
         self.required_map = {}
         self.environ_map = {}
+        self.zconfig_options = []
         self.add(None, None, "h", "help", self.help)
         self.add("configfile", None, "C:", "configure=")
+        self.add(None, None, "X:", handler=self.zconfig_options.append)
 
     def help(self, dummy):
         """Print a long help message (self.doc) to stdout and exit(0).
@@ -247,6 +249,9 @@
                 if name and value is not None:
                     setattr(self, name, value)
 
+        if self.zconfig_options and self.configfile is None:
+            self.usage("configuration overrides (-X) cannot be used"
+                       " without a configuration file")
         if self.configfile is not None:
             # Process config file
             self.load_schema()
@@ -294,7 +299,8 @@
 
     def load_configfile(self):
         self.configroot, self.confighandlers = \
-            ZConfig.loadConfig(self.schema, self.configfile)
+            ZConfig.loadConfig(self.schema, self.configfile,
+                               self.zconfig_options)
 
     def load_logconf(self, sectname="eventlog"):
         parts = sectname.split(".")