summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2011-08-31 09:01:10 +0000
committerGordon Sim <gsim@apache.org>2011-08-31 09:01:10 +0000
commit511e47dfb9c4291b4a738426fdba35fd01cace32 (patch)
tree86fbcccb5b62d8b86dd9815786fa8b82f488a38c /cpp
parent65c00e07d38b43a70a58fdda3ef4d6a5f803507b (diff)
downloadqpid-python-511e47dfb9c4291b4a738426fdba35fd01cace32.tar.gz
QPID-3333: Patch from Anthony Foglia - Handle amqp/list and amqp/map content (0013)
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1163537 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r--cpp/bindings/qpid/python/python.i25
1 files changed, 21 insertions, 4 deletions
diff --git a/cpp/bindings/qpid/python/python.i b/cpp/bindings/qpid/python/python.i
index 96d8e4b08e..9d45bf54ee 100644
--- a/cpp/bindings/qpid/python/python.i
+++ b/cpp/bindings/qpid/python/python.i
@@ -251,9 +251,11 @@ static PyObject* pTransportFailure;
subject=None, user_id=None, reply_to=None,
correlation_id=None, durable=None, priority=None,
ttl=None, properties=None):
- this = _cqpid.new_Message(content if content else '')
+ this = _cqpid.new_Message('')
try: self.this.append(this)
except: self.this = this
+ if content :
+ self.content = content
if content_type != UNSPECIFIED :
self.content_type = content_type
if id is not None :
@@ -279,9 +281,24 @@ static PyObject* pTransportFailure;
for k, v in properties.iteritems() :
self.setProperty(k, v)
- __swig_getmethods__["content"] = getContent
- __swig_setmethods__["content"] = setContent
- if _newclass: content = _swig_property(getContent, setContent)
+ def _get_content(self) :
+ if self.content_type == "amqp/list" :
+ return decodeList(self)
+ if self.content_type == "amqp/map" :
+ return decodeMap(self)
+ return self.getContent()
+ def _set_content(self, content) :
+ if isinstance(content, basestring) :
+ self.setContent(content)
+ elif isinstance(content, list) or isinstance(content, dict) :
+ encode(content, self)
+ else :
+ # Not a type we can handle. Try setting it anyway,
+ # although this will probably lead to a swig error
+ self.setContent(content)
+ __swig_getmethods__["content"] = _get_content
+ __swig_setmethods__["content"] = _set_content
+ if _newclass: content = _swig_property(_get_content, _set_content)
__swig_getmethods__["content_type"] = getContentType
__swig_setmethods__["content_type"] = setContentType