1.1 --- a/actions/PostMessage.py Sun Oct 28 22:27:35 2012 +0100
1.2 +++ b/actions/PostMessage.py Mon Oct 29 22:36:16 2012 +0100
1.3 @@ -10,7 +10,7 @@
1.4 from MoinMoin.log import getLogger
1.5 from MoinMoin.user import User
1.6 from MoinSupport import *
1.7 -from MoinMessage import GPG, MoinMessageError
1.8 +from MoinMessage import GPG, Message, MoinMessageError
1.9 from email.parser import Parser
1.10
1.11 try:
1.12 @@ -199,34 +199,29 @@
1.13 writeHeaders(request, "text/plain", getMetadata(self.page), "403 Forbidden")
1.14 request.write("The message could not be verified.")
1.15
1.16 - def handle_message_content(self, message):
1.17 + def handle_message_content(self, content):
1.18
1.19 - "Handle the given 'message'."
1.20 + "Handle the given message 'content'."
1.21
1.22 request = self.request
1.23
1.24 - # Handle a single part.
1.25 -
1.26 - if not message.is_multipart():
1.27 - self.handle_message_parts([message], to_replace(message))
1.28 + # Interpret the content as one or more updates.
1.29
1.30 - # Handle multiple parts.
1.31 + message = Message()
1.32 + message.handle_message(content)
1.33
1.34 - # This can be a collection of updates, with each update potentially being a
1.35 - # collection of alternative representations.
1.36 + for update in message.updates:
1.37 +
1.38 + # Handle a single part.
1.39
1.40 - elif is_collection(message):
1.41 - for part in message.get_payload():
1.42 - if part.is_multipart():
1.43 - self.handle_message_parts(part.get_payload(), to_replace(part))
1.44 - else:
1.45 - self.handle_message_parts([part], to_replace(part))
1.46 + if not update.is_multipart():
1.47 + self.handle_message_parts([update], to_replace(update))
1.48
1.49 - # Or it can be a collection of alternative representations for a single
1.50 - # update.
1.51 + # Or a collection of alternative representations for a single
1.52 + # update.
1.53
1.54 - else:
1.55 - self.handle_message_parts(message.get_payload(), to_replace(message))
1.56 + else:
1.57 + self.handle_message_parts(update.get_payload(), to_replace(update))
1.58
1.59 # Default output.
1.60