moksha/lib/helpers.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
New commits: commit d103b4c8c3670f765f6dc1f24f5987b6b661f834 Author: John (J5) Palmieri johnp@redhat.com Date: Fri Mar 20 16:35:17 2009 -0400
fix argument passing to apps
* unicode arguments are coverted to string before being jsonified - this should mostlikely be fixed in simplejson so we can have unicode arguments passed to javascript (right now they get rendered as u'' which javascript does not understand - another fix might be to subclass the unicode object and return moksha_unicode('') from __repr__ and write a function which decodes Python unicode to JS strings * make argument filling recursive on dicts - e.g. if the param username is accepted by the controller update the apps username params. This includes both {'username':''} and {'filters':{'username':''}}
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py index ca73134..53a72bc 100644 --- a/moksha/lib/helpers.py +++ b/moksha/lib/helpers.py @@ -30,12 +30,22 @@ def _update_params(params, d): for k in params.iterkeys():
if d and (k in d): - p[k] = d[k] + value = d[k] else: - p[k] = params[k] - - if isinstance(p[k], dict) or isinstance(p[k], list): - p[k] = json.dumps(p[k]) + value = params[k] + + # recursive dicts also get updated + # by the passed params + if isinstance(value, unicode): + value = str(value) + if isinstance(value, dict): + value = _update_params(value, d) + value = json.dumps(value) + elif isinstance(value, list): + # FIXME: This should be recursive + value = json.dumps(value) + + p[k] = value
return p
moksha-commits@lists.fedorahosted.org