changeset 1630:24c1a4b29c86

items/__init__.py: comment policy='duck' argument passed to Flatland.Dict.set
author Cheer Xiao <xiaqqaix@gmail.com>
date Mon, 06 Aug 2012 00:46:27 +0800
parents 8b7a85055643
children c1eb8d519084 96d54f9d4283
files MoinMoin/items/__init__.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/__init__.py	Mon Aug 06 00:10:47 2012 +0800
+++ b/MoinMoin/items/__init__.py	Mon Aug 06 00:46:27 2012 +0800
@@ -310,7 +310,11 @@
 
         def _load(self, item):
             meta = item.prepare_meta_for_modify(item.meta)
-            self['meta_form'].set(meta, 'duck')
+            # Default value of `policy` argument of Flatland.Dict.set's is
+            # 'strict', which causes KeyError to be thrown when meta contains
+            # meta keys that are not present in self['meta_form']. Setting
+            # policy to 'duck' suppresses this behavior.
+            self['meta_form'].set(meta, policy='duck')
             for k in self['meta_form'].field_schema_mapping.keys():
                 meta.pop(k, None)
             self['extra_meta_text'].set(item.meta_dict_to_text(meta))