# HG changeset patch # User Paul Boddie # Date 1390693449 -3600 # Node ID 3315bed653f6a5d36e0e88d8198f9835552bf319 # Parent e8547266a21f08533bc71d33cd03a0b61f82c2bf Return an appropriate response when no updates can be handled. diff -r e8547266a21f -r 3315bed653f6 actions/PostMessage.py --- a/actions/PostMessage.py Mon Jan 13 00:18:40 2014 +0100 +++ b/actions/PostMessage.py Sun Jan 26 00:44:09 2014 +0100 @@ -28,27 +28,37 @@ # Handle each update. all_successful = True + any_successful = False for update in message.updates: # Handle a single part. if not is_collection(update): - all_successful = all_successful and self.handle_message_parts(message, [update], update) + success = self.handle_message_parts(message, [update], update) # Or a collection of alternative representations for a single # update. else: - all_successful = all_successful and self.handle_message_parts(message, update.get_payload(), update) + success = self.handle_message_parts(message, update.get_payload(), update) + + all_successful = all_successful and success + any_successful = any_successful or success # Default output. - writeHeaders(request, "text/plain", getMetadata(self.page), "200 OK") + if any_successful: + writeHeaders(request, "text/plain", getMetadata(self.page), "200 OK") + else: + writeHeaders(request, "text/plain", getMetadata(self.page), "403 Forbidden") + if all_successful: request.write("All updates were successful.") + elif any_successful: + request.write("Some updates were unsuccessful.") else: - request.write("Some updates were unsuccessful.") + request.write("No updates were successful.") def handle_message_parts(self, message, parts, update):