diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2007-11-07 20:46:36 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2007-11-07 20:46:36 +0000 |
| commit | c9900041bf70ac76a4eb8753965fe24426ba8cd4 (patch) | |
| tree | 9f8f4d8e54358a59e6f86cf70db15fb37c26ca90 /python/qpid/__init__.py | |
| parent | 710b8a1f1285b9aa5bccee5b1906500667dd7bc5 (diff) | |
| download | qpid-python-c9900041bf70ac76a4eb8753965fe24426ba8cd4.tar.gz | |
added factory for structs, and made default spec loading based on AMQP_SPEC environment variable
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@592888 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/__init__.py')
| -rw-r--r-- | python/qpid/__init__.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/python/qpid/__init__.py b/python/qpid/__init__.py index 7afebaf73b..ff9cc04df8 100644 --- a/python/qpid/__init__.py +++ b/python/qpid/__init__.py @@ -21,10 +21,19 @@ import spec, codec, connection, content, peer, delegate, client class Struct: - def __init__(self, type): + def __init__(self, type, *args, **kwargs): self.__dict__["type"] = type self.__dict__["_values"] = {} + if len(args) > len(self.type.fields): + raise TypeError("too many args") + + for a, f in zip(args, self.type.fields): + self.set(f.name, a) + + for k, a in kwargs.items(): + self.set(k, a) + def _check(self, attr): field = self.type.fields.byname.get(attr) if field == None: |
