Skip to content

Commit 79f78a4

Browse files
committed
Create operation proxy objects on initialization
1 parent 26ba905 commit 79f78a4

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/zeep/client.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import copy
2+
import itertools
23
import logging
34
from contextlib import contextmanager
45

@@ -50,6 +51,9 @@ def __init__(self, client, binding, **binding_options):
5051
self._client = client
5152
self._binding_options = binding_options
5253
self._binding = binding
54+
self._operations = {
55+
name: OperationProxy(self, name) for name in self._binding.all()
56+
}
5357

5458
def __getattr__(self, key):
5559
"""Return the OperationProxy for the given key.
@@ -66,17 +70,14 @@ def __getitem__(self, key):
6670
6771
"""
6872
try:
69-
self._binding.get(key)
70-
except ValueError:
73+
return self._operations[key]
74+
except KeyError:
7175
raise AttributeError('Service has no operation %r' % key)
72-
return OperationProxy(self, key)
7376

7477
def __dir__(self):
7578
""" Return the names of the operations. """
76-
return list(dir(super(ServiceProxy, self))
77-
+ list(self.__dict__)
78-
+ list(self._binding.port_type.operations))
79-
# using list() on the dicts for Python 3 compatibility
79+
return list(itertools.chain(
80+
dir(super(ServiceProxy, self)), self._operations))
8081

8182

8283
class Factory(object):

src/zeep/wsdl/definitions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ def __repr__(self):
141141
return '<%s(name=%r, port_type=%r)>' % (
142142
self.__class__.__name__, self.name.text, self.port_type)
143143

144+
def all(self):
145+
return self._operations
146+
144147
def get(self, key):
145148
try:
146149
return self._operations[key]

0 commit comments

Comments
 (0)