def get_manager(request, uid): manager = Manager.get_by_id(uid) if not manager: data = {'api_success': False, 'api_msg': 'Manager %s not found' % uid} return render_json_response(data, status=404) if request.method == 'GET': return render_json_response(manager.to_json()) if request.method == 'DELETE': manager.key.delete() data = {'api_success': True, 'api_msg': 'Manager %s deleted' % uid} return render_json_response(data) if request.method == 'PUT': model = simplejson.loads(request.data) manager.communication = Communication.from_json(model.get('communication', {})) manager.telephone = Telephone.from_json(model.get('telephone', {})) manager.address = Address.from_json(model.get('address', {})) manager.name = model.get('name', '') manager.last_name = model.get('last_name', '') manager.is_display = model.get('is_display', False) manager.put() data = {'api_success': True, 'api_msg': 'Manager %s updated' % uid} data.update(manager.to_json()) return render_json_response(data)