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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Dec 2 13:11:28 CET 2008


Author: bh
Date: 2008-12-02 13:11:28 +0100 (Tue, 02 Dec 2008)
New Revision: 53

Modified:
   trunk/ChangeLog
   trunk/server/osaas/http/run.py
Log:
* server/osaas/http/run.py (OptionStack): Add doc-string.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-12-02 12:06:37 UTC (rev 52)
+++ trunk/ChangeLog	2008-12-02 12:11:28 UTC (rev 53)
@@ -1,5 +1,9 @@
 2008-12-02  Bernhard Herzog  <bh at intevation.de>
 
+	* server/osaas/http/run.py (OptionStack): Add doc-string.
+
+2008-12-02  Bernhard Herzog  <bh at intevation.de>
+
 	* server/osaas/http/run.py (ServerProgram.create_option_parser):
 	New option --log-level to set the log level of access-log and
 	error-log.  Defaults to INFO

Modified: trunk/server/osaas/http/run.py
===================================================================
--- trunk/server/osaas/http/run.py	2008-12-02 12:06:37 UTC (rev 52)
+++ trunk/server/osaas/http/run.py	2008-12-02 12:11:28 UTC (rev 53)
@@ -24,6 +24,23 @@
 
 class OptionStack(object):
 
+    """A combination of multiple option sources
+
+    Programs usually have three sources of options: defaults,
+    configuration files, and command line arguments.  This class
+    combines these three sources in the form of optparse.Values
+    instances.  An OptionStack instance behaves similarly to an
+    optparse.Values instance.  Attributes of an instance are looked up
+    in the command line arguments, configuration file and defaults (in
+    that order).  If an attribute is not found in any of the option
+    sources, an AttributeError is raised.
+
+    There's one special attribute, option_list, which is a list of the
+    optparse.Option instances that specify the options.  This is meant
+    to be used by code that reads a config file to convert the string
+    representation to a suitable internal representation.
+    """
+
     def __init__(self, option_list, default_opts, file_opts, commandline_opts):
         self.option_list = option_list
         self.__opts = (commandline_opts, file_opts, default_opts)
@@ -37,6 +54,7 @@
     def set_file_option(self, name, value):
         setattr(self.__opts[1], name, value)
 
+
 class ProgramWithOptions(object):
 
     optparse_option_class = None



More information about the Osaas-commits mailing list