[Mpuls-commits] r1874 - in wasko/branches/2.0: . mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Mar 1 13:08:49 CET 2010
Author: bh
Date: 2010-03-01 13:08:48 +0100 (Mon, 01 Mar 2010)
New Revision: 1874
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/mpulsweb/lib/config.py
Log:
* mpulsweb/lib/config.py (merge): Expand doc-string and mention
unmergable_dict
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-03-01 12:08:05 UTC (rev 1873)
+++ wasko/branches/2.0/ChangeLog 2010-03-01 12:08:48 UTC (rev 1874)
@@ -1,5 +1,10 @@
2010-03-01 Bernhard Herzog <bh at intevation.de>
+ * mpulsweb/lib/config.py (merge): Expand doc-string and mention
+ unmergable_dict
+
+2010-03-01 Bernhard Herzog <bh at intevation.de>
+
* mpulsweb/lib/config.py (unmergable_dict): New. Class to use
instead of plain dict objects as default values MpulsConfig.
Instances of unmergable_dict will not be merged recursively, so
Modified: wasko/branches/2.0/mpulsweb/lib/config.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/config.py 2010-03-01 12:08:05 UTC (rev 1873)
+++ wasko/branches/2.0/mpulsweb/lib/config.py 2010-03-01 12:08:48 UTC (rev 1874)
@@ -36,7 +36,20 @@
# as pylonspath is empty
def merge(a, b):
- '''recursive merge b into a. a is default, b is userdefined'''
+ """Recursively update the items of a with the corresponding values of b.
+
+ Both a and b should be dictionaries. All values of a which have
+ corresponding values in b, i.e. values for the same keys, are merged
+ into a. If the values in b and a are dictionaries, they will be
+ merged recursively, otherwise, the value of be will be inserted into
+ a as the new value.
+
+ The recursive update of dictionaries makes it difficult to have
+ dictionaries as values where the user should be able to add keys.
+ Simply using a dictionary object that is not a direct instance of
+ dict works around the recursive merge. The unmergable_dict class
+ can be used to create instances like this.
+ """
changes = []
for ka, va in a.iteritems():
try:
More information about the Mpuls-commits
mailing list