diff options
| author | Gordon Sim <gsim@apache.org> | 2007-02-07 15:36:01 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2007-02-07 15:36:01 +0000 |
| commit | c9ca9e1767b66d31fe9180fbd245508f60eaba8f (patch) | |
| tree | 84455b9c7ed31e3d23f27643e48883902cbdb838 /python/qpid/codec.py | |
| parent | 1977153241e86e93b237d2ed7fe02883d44646c5 (diff) | |
| download | qpid-python-c9ca9e1767b66d31fe9180fbd245508f60eaba8f.tar.gz | |
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/branches/qpid.0-9@504590 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/codec.py')
| -rw-r--r-- | python/qpid/codec.py | 27 |
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)): |
