summaryrefslogtreecommitdiff
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
commit95ef11424c04263ae119bcca11bc0ea44b20c6bb (patch)
tree87cf3fa8164acb2abd01c58b7664225396d8e1cf
parenta152beaeb72192202fa23c7309bf086e636ee0a6 (diff)
downloadqpid-python-95ef11424c04263ae119bcca11bc0ea44b20c6bb.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@1163537 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/bindings/qpid/python/python.i25
1 files changed, 21 insertions, 4 deletions
diff --git a/qpid/cpp/bindings/qpid/python/python.i b/qpid/cpp/bindings/qpid/python/python.i
index 96d8e4b08e..9d45bf54ee 100644
--- a/qpid/cpp/bindings/qpid/python/python.i
+++ b/qpid/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