Author: rhs
Date: Mon Jul 12 13:43:27 2010
New Revision: 963280
URL: http://svn.apache.org/viewvc?rev=963280&view=rev
Log:
fixed payload of None for text/plain messages
Modified:
qpid/trunk/qpid/python/qpid/messaging/message.py
qpid/trunk/qpid/python/qpid/tests/messaging/message.py
Modified: qpid/trunk/qpid/python/qpid/messaging/message.py
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/messaging/message.py?rev=963280&r1=963279&r2=963280&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/messaging/message.py (original)
+++ qpid/trunk/qpid/python/qpid/messaging/message.py Mon Jul 12 13:43:27 2010
@@ -49,11 +49,23 @@ TYPE_MAPPINGS={
DEFAULT_CODEC = (lambda x: x, lambda x: x)
+def encode_text_plain(x):
+ if x is None:
+ return None
+ else:
+ return x.encode("utf8")
+
+def decode_text_plain(x):
+ if x is None:
+ return None
+ else:
+ return x.decode("utf8")
+
TYPE_CODEC={
"amqp/map": codec("map"),
"amqp/list": codec("list"),
- "text/plain; charset=utf8": (lambda x: x.encode("utf8"), lambda x:
x.decode("utf8")),
- "text/plain": (lambda x: x.encode("utf8"), lambda x: x.decode("utf8")),
+ "text/plain; charset=utf8": (encode_text_plain, decode_text_plain),
+ "text/plain": (encode_text_plain, decode_text_plain),
"": DEFAULT_CODEC,
None: DEFAULT_CODEC
}
Modified: qpid/trunk/qpid/python/qpid/tests/messaging/message.py
URL:
http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/tests/messaging/message.py?rev=963280&r1=963279&r2=963280&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/tests/messaging/message.py (original)
+++ qpid/trunk/qpid/python/qpid/tests/messaging/message.py Mon Jul 12 13:43:27
2010
@@ -111,3 +111,9 @@ class MessageEchoTests(Base):
def testContentTypeUnknown(self):
msg = Message(content_type = "this-content-type-does-not-exist")
self.check(msg)
+
+ def testTextPlain(self):
+ self.check(Message(content_type="text/plain", content="asdf"))
+
+ def testTextPlainEmpty(self):
+ self.check(Message(content_type="text/plain"))
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]