def _updateuser(self, request, user_nickname): ''' Edit user. Return 400 if request is invalid. Return 204 on success. ''' try: usermodel = UserModel(user_nickname) except Exception as e: print "Could not add the data "+ str(e) traceback.print_exc() return Response(status = 400) if usermodel is None: return Response(status = status.HTTP_404_NOT_FOUND) #request.DATA contains a dictionary with the entity body input. #Deserialize the data and modify the model try: #EXTRACT THE PRIVATE DATA email = request.DATA['email'] description = request.DATA.get("description","") #SET VALUES TO USER usermodel.nickname = user_nickname usermodel.description = description usermodel.email = email try: if sys.argv[1] != "test": u = AuthUser.objects.get(username__exact=user_nickname) u.set_password(request.DATA.get("password", None)) u.save() except IndexError: pass except Exception as e: print "Could not add the data "+ str(e) traceback.print_exc() return Response(status = 400) #Update the model to the database database.edit_user(usermodel) url = reverse("user", (user_nickname,), request=request) return Response(status=status.HTTP_204_NO_CONTENT, headers={"Location":url})