[Osaas-commits] r7 - in trunk: . server/osaas server/osaas/http server/test

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Aug 27 19:51:26 CEST 2007


Author: bh
Date: 2007-08-27 19:51:26 +0200 (Mon, 27 Aug 2007)
New Revision: 7

Modified:
   trunk/ChangeLog
   trunk/server/osaas/config.py
   trunk/server/osaas/http/run.py
   trunk/server/osaas/run.py
   trunk/server/test/test_run.py
Log:
* server/osaas/http/run.py (OptionStack.__init__): New parameter
for a list a list of option definitions.
(ProgramWithOptions.parse_options): pass the option parser's
option_list to the OptionStack instance

* server/osaas/config.py (read_config_file): Work directly on the
option stack instead of passing a list of option and a setter
function

* server/osaas/run.py (OSAASServerProgram.create_option_parser):
Do not bind the parser to self.
(OSAASServerProgram.read_config_file): Adapt to
config.read_config_file changes.

* server/test/test_run.py (TestOptionStack.test): Adapt to
OptionStack changes


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-08-27 17:30:41 UTC (rev 6)
+++ trunk/ChangeLog	2007-08-27 17:51:26 UTC (rev 7)
@@ -1,5 +1,24 @@
 2007-08-27  Bernhard Herzog  <bh at intevation.de>
 
+	* server/osaas/http/run.py (OptionStack.__init__): New parameter
+	for a list a list of option definitions.
+	(ProgramWithOptions.parse_options): pass the option parser's
+	option_list to the OptionStack instance
+
+	* server/osaas/config.py (read_config_file): Work directly on the
+	option stack instead of passing a list of option and a setter
+	function
+
+	* server/osaas/run.py (OSAASServerProgram.create_option_parser):
+	Do not bind the parser to self.
+	(OSAASServerProgram.read_config_file): Adapt to
+	config.read_config_file changes.
+
+	* server/test/test_run.py (TestOptionStack.test): Adapt to
+	OptionStack changes
+
+2007-08-27  Bernhard Herzog  <bh at intevation.de>
+
 	* server/startosaas.py: Add missing #! line
 
 2007-08-27  Bernhard Herzog  <bh at intevation.de>

Modified: trunk/server/osaas/config.py
===================================================================
--- trunk/server/osaas/config.py	2007-08-27 17:30:41 UTC (rev 6)
+++ trunk/server/osaas/config.py	2007-08-27 17:51:26 UTC (rev 7)
@@ -36,10 +36,11 @@
                                  " content" % path)
     return value_node.data
 
-def read_config_file(filename, options, setter):
+def read_config_file(filename, opts):
     dom = parse(filename)
-    for option in options:
+    for option in opts.option_list:
         if option.dest is not None and option.xml_path:
             value = find_xml_path(dom, option.xml_path)
             if value is not None:
-                setter(option.dest, option.check_value(option.xml_path, value))
+                opts.set_file_option(option.dest,
+                                     option.check_value(option.xml_path, value))

Modified: trunk/server/osaas/http/run.py
===================================================================
--- trunk/server/osaas/http/run.py	2007-08-27 17:30:41 UTC (rev 6)
+++ trunk/server/osaas/http/run.py	2007-08-27 17:51:26 UTC (rev 7)
@@ -23,7 +23,8 @@
 
 class OptionStack(object):
 
-    def __init__(self, default_opts, file_opts, commandline_opts):
+    def __init__(self, option_list, default_opts, file_opts, commandline_opts):
+        self.option_list = option_list
         self.__opts = (commandline_opts, file_opts, default_opts)
 
     def __getattr__(self, attr):
@@ -67,7 +68,8 @@
         default_opts = parser.get_default_values()
         configfile_opts = optparse.Values()
         commandline_opts, rest = parser.parse_args(args, optparse.Values())
-        opts = OptionStack(default_opts, configfile_opts, commandline_opts)
+        opts = OptionStack(parser.option_list, default_opts, configfile_opts,
+                           commandline_opts)
         self.read_config_file(opts)
         return opts, rest
 

Modified: trunk/server/osaas/run.py
===================================================================
--- trunk/server/osaas/run.py	2007-08-27 17:30:41 UTC (rev 6)
+++ trunk/server/osaas/run.py	2007-08-27 17:51:26 UTC (rev 7)
@@ -14,21 +14,20 @@
     optparse_option_class = OSAASOption
 
     def create_option_parser(self, **kw):
-        self.parser = ServerProgram.create_option_parser(self, **kw)
+        parser = ServerProgram.create_option_parser(self, **kw)
         for name in ["port", "access-log", "error-log"]:
             path = "OSAASConfig/" + "".join([part.capitalize()
                                              for part in name.split("-")])
-            self.parser.get_option("--" + name).xml_path = path
-        self.parser.add_option("--userdb-file", xml_path="OSAASConfig/UserDB")
-        return self.parser
+            parser.get_option("--" + name).xml_path = path
+        parser.add_option("--userdb-file", xml_path="OSAASConfig/UserDB")
+        return parser
 
     def instantiate_server(self, server_class, server_address, opts, **kw):
         return server_class(server_address, userdbfile=opts.userdb_file, **kw)
 
     def read_config_file(self, opts):
         if opts.config_file is not None:
-            read_config_file(opts.config_file, self.parser.option_list,
-                             opts.set_file_option)
+            read_config_file(opts.config_file, opts)
 
 
 def main():

Modified: trunk/server/test/test_run.py
===================================================================
--- trunk/server/test/test_run.py	2007-08-27 17:30:41 UTC (rev 6)
+++ trunk/server/test/test_run.py	2007-08-27 17:51:26 UTC (rev 7)
@@ -112,7 +112,7 @@
         configfile_opts = optparse.Values()
         commandline_opts, rest = parser.parse_args(["--config-file=/etc/cfg"],
                                                    optparse.Values())
-        opts = OptionStack(default_opts, configfile_opts, commandline_opts)
+        opts = OptionStack([], default_opts, configfile_opts, commandline_opts)
 
         opts.set_file_option("log_file", "/var/log/my.log")
 



More information about the Osaas-commits mailing list