1.1 --- a/actions/PostMessage.py Tue Dec 17 14:11:38 2013 +0100
1.2 +++ b/actions/PostMessage.py Sat Dec 21 01:48:54 2013 +0100
1.3 @@ -9,7 +9,7 @@
1.4 from MoinMoin.Page import Page
1.5 from MoinMoin.PageEditor import PageEditor
1.6 from MoinSupport import getMetadata, writeHeaders
1.7 -from MoinMessage import is_collection, to_replace, to_store
1.8 +from MoinMessage import is_collection, to_replace, to_store, get_update_action
1.9 from MoinMessageSupport import MoinMessageAction
1.10
1.11 Dependencies = ['pages']
1.12 @@ -26,22 +26,28 @@
1.13
1.14 # Handle each update.
1.15
1.16 + all_successful = True
1.17 +
1.18 for update in message.updates:
1.19
1.20 # Handle a single part.
1.21
1.22 if not is_collection(update):
1.23 - self.handle_message_parts([update], update)
1.24 + all_successful = all_successful and self.handle_message_parts([update], update)
1.25
1.26 # Or a collection of alternative representations for a single
1.27 # update.
1.28
1.29 else:
1.30 - self.handle_message_parts(update.get_payload(), update)
1.31 + all_successful = all_successful and self.handle_message_parts(update.get_payload(), update)
1.32
1.33 # Default output.
1.34
1.35 - writeHeaders(request, "text/plain", getMetadata(self.page), "204 No Content")
1.36 + writeHeaders(request, "text/plain", getMetadata(self.page), "200 OK")
1.37 + if all_successful:
1.38 + request.write("All updates were successful.")
1.39 + else:
1.40 + request.write("Some updates were unsuccessful.")
1.41
1.42 def handle_message_parts(self, parts, update):
1.43
1.44 @@ -53,6 +59,13 @@
1.45
1.46 request = self.request
1.47
1.48 + # Test for privileges to change the page or message store.
1.49 +
1.50 + update_action = get_update_action(update)
1.51 +
1.52 + if not self.can_perform_action(update_action):
1.53 + return False
1.54 +
1.55 # Handle the different update actions.
1.56 # Update a message store for the page.
1.57
1.58 @@ -95,6 +108,8 @@
1.59
1.60 self.page = Page(request, self.pagename)
1.61
1.62 + return True
1.63 +
1.64 # Action function.
1.65
1.66 def execute(pagename, request):