From fc0d97db1ea3ec9922516685d82c42ae6dd47770 Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Thu, 25 Apr 2013 16:54:36 -0400 Subject: [PATCH] * Parameters._flatten_(): Added workaround to avoid evaluating the dict values while flattening the list. This is critical for avoiding evaluation of the 'active' members. --- params/params_flat.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/params/params_flat.py b/params/params_flat.py index e7b1d6a..91110a8 100644 --- a/params/params_flat.py +++ b/params/params_flat.py @@ -122,6 +122,8 @@ class Parameters(dict): return dict.__getitem__(self.ref(), key) def __iter__(self): return dict.__iter__(self.ref()) + def __dict_object__(self): + return self.ref() def __init__(self, *_override_dicts_, **_opts_): """ @@ -332,7 +334,10 @@ class Parameters(dict): _list_ = self.__dict__["_list_"] for D in _list_[::-1]: #FIXME# if D is a Parameters object then we must recursively flatten it too - K.update([ (k,D[k]) for k in flatten_dict(D) ]) + if isinstance(D, Parameters._self_weakref_): + K.update(D.__dict_object__()) + else: + K.update(flatten_dict(D)) return K def _update_(self, srcdict):