diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2007-08-10 15:55:16 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2007-08-10 15:55:16 +0000 |
| commit | 01652ef4ec4d7a92bfdcf677c27fb28968398bc6 (patch) | |
| tree | 495a8d994def30a30512beaf4077643c41cff332 /python/qpid/__init__.py | |
| parent | 6577b14632d81c15482cb0793e01166cdb28eaff (diff) | |
| download | qpid-python-01652ef4ec4d7a92bfdcf677c27fb28968398bc6.tar.gz | |
added support for unpacked structs and execution.result
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@564637 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/__init__.py')
| -rw-r--r-- | python/qpid/__init__.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/python/qpid/__init__.py b/python/qpid/__init__.py index 4363f175fb..4aeccae38e 100644 --- a/python/qpid/__init__.py +++ b/python/qpid/__init__.py @@ -18,3 +18,26 @@ # import spec, codec, connection, content, peer, delegate, client + +class Struct: + + def __init__(self, type): + self.__dict__["type"] = type + self.__dict__["_values"] = {} + + def _check(self, attr): + field = self.type.fields.byname.get(attr) + if field == None: + raise AttributeError(attr) + return field + + def __setattr__(self, attr, value): + self._check(attr) + self._values[attr] = value + + def __getattr__(self, attr): + field = self._check(attr) + return self._values.get(attr, field.default()) + + def __str__(self): + return "%s %s" % (self.type.type, self._values) |
