diff options
author | Rafael H. Schloming <rhs@apache.org> | 2010-03-23 15:32:48 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2010-03-23 15:32:48 +0000 |
commit | 20c6e290c0bbb2865821ec7c50af923c974350c5 (patch) | |
tree | ce736fe83ecf0e4a5238285fa49747b846ed8d2d /python/qpid/messaging/message.py | |
parent | fe99d24c4084b2cb2479b820a5b44378d1812ffc (diff) | |
download | qpid-python-20c6e290c0bbb2865821ec7c50af923c974350c5.tar.gz |
provide default codec for unknown content types
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@926623 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/messaging/message.py')
-rw-r--r-- | python/qpid/messaging/message.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/python/qpid/messaging/message.py b/python/qpid/messaging/message.py index a9660b05b1..d89fa00dc3 100644 --- a/python/qpid/messaging/message.py +++ b/python/qpid/messaging/message.py @@ -47,20 +47,22 @@ TYPE_MAPPINGS={ None.__class__: None } +DEFAULT_CODEC = (lambda x: x, lambda x: x) + 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")), - "": (lambda x: x, lambda x: x), - None: (lambda x: x, lambda x: x) + "": DEFAULT_CODEC, + None: DEFAULT_CODEC } def get_type(content): return TYPE_MAPPINGS[content.__class__] def get_codec(content_type): - return TYPE_CODEC[content_type] + return TYPE_CODEC.get(content_type, DEFAULT_CODEC) UNSPECIFIED = object() |