summaryrefslogtreecommitdiff
path: root/python/qpid/codec.py
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-03-19 19:39:55 +0000
committerAlan Conway <aconway@apache.org>2007-03-19 19:39:55 +0000
commita96bf8ba7ce40d12ee4b3f85002133e1738225a4 (patch)
tree13db6eefd1120c228c11ff7d94a500bbbd4d1289 /python/qpid/codec.py
parent27e6ef93eea10d1aeb7ca6a6a37926aa5f85c380 (diff)
downloadqpid-python-a96bf8ba7ce40d12ee4b3f85002133e1738225a4.tar.gz
Merged revisions 504590 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9 ........ r504590 | gsim | 2007-02-07 10:36:01 -0500 (Wed, 07 Feb 2007) | 6 lines Added support for receiving and sending of references Added asynchronous mode to channels (responses can be tracked via a future, rather than blocking on each request) Added ability to override server suggested connection tune params Added two tests for reference functionality (more to follow) ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@520061 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/codec.py')
-rw-r--r--python/qpid/codec.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/python/qpid/codec.py b/python/qpid/codec.py
index 205405894a..3c1e73c2e6 100644
--- a/python/qpid/codec.py
+++ b/python/qpid/codec.py
@@ -26,6 +26,7 @@ fields.
from cStringIO import StringIO
from struct import *
+from reference import ReferenceId
class EOF(Exception):
pass
@@ -195,14 +196,24 @@ class Codec:
return self.decode_longlong()
def encode_content(self, s):
- # XXX
- self.encode_octet(0)
- self.encode_longstr(s)
-
- def decode_content(self):
- # XXX
- self.decode_octet()
- return self.decode_longstr()
+ # content can be passed as a string in which case it is assumed to
+ # be inline data, or as an instance of ReferenceId indicating it is
+ # a reference id
+ if isinstance(s, ReferenceId):
+ self.encode_octet(1)
+ self.encode_longstr(s.id)
+ else:
+ self.encode_octet(0)
+ self.encode_longstr(s)
+
+ def decode_content(self):
+ # return a string for inline data and a ReferenceId instance for
+ # references
+ type = self.decode_octet()
+ if type == 0:
+ return self.decode_longstr()
+ else:
+ return ReferenceId(self.decode_longstr())
def test(type, value):
if isinstance(value, (list, tuple)):