def change_agent_mapping(request, solutionId): user = request.user response = 'failure' if request.method == 'POST': params = request.POST if u'json' in params: try: solution = get_solution_or_404(user, id=solutionId) config = solution.get_config_filepath() agents = json.loads(params[u'json']) # TODO Y U forgot to handle this? Validator.validateAgentMapping(agents) # TODO server-side validation goes here # also check IDs!! tree = SolutionSpecification.add_agents_to_xml(config, agents) tree.write(config) response = 'ok' except ValueError, e: response = str(e)