def request_template_to_dict(request): obj = extractRequestObj(request) if not isinstance(obj, dict): # Should probably also check whether the object is a valid # collection. return {} template = obj.get('template', {}) return template_to_dict(template)
def updateJsonForm(form): # As a JSON request is a JSON, read from stdin of request. request = form.request obj = extractRequestObj(request) if not isinstance(obj, dict): # Not a JSON object type (hashtable/dict) return # XXX the second part of the prefixes are assumptions. prefix = '%s%s' % (form.prefix, 'widgets.') a_prefix = '%s%s' % (form.prefix, 'buttons.') keys = form.fields.keys() fields = obj.get('fields', {}) action = obj.get('actions', {}) # XXX might be a good idea to report errors to client if malformed # value types are received. objToRequest(fields, form.fields.keys(), prefix, request) objToRequest(action, form.buttons.keys(), a_prefix, request)