MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / ServiceSelector

Class ServiceSelector

suds/client.py:275–374  ·  view source on GitHub ↗

The B{service} selector is used to select a web service. In most cases, the wsdl only defines (1) service in which access by subscript is passed through to a L{PortSelector}. This is also the behavior when a I{default} service has been specified. In cases where multiple servic

Source from the content-addressed store, hash-verified

273
274
275class ServiceSelector:
276 """
277 The B{service} selector is used to select a web service.
278 In most cases, the wsdl only defines (1) service in which access
279 by subscript is passed through to a L{PortSelector}. This is also the
280 behavior when a I{default} service has been specified. In cases
281 where multiple services have been defined and no default has been
282 specified, the service is found by name (or index) and a L{PortSelector}
283 for the service is returned. In all cases, attribute access is
284 forwarded to the L{PortSelector} for either the I{first} service or the
285 I{default} service (when specified).
286 @ivar __client: A suds client.
287 @type __client: L{Client}
288 @ivar __services: A list of I{wsdl} services.
289 @type __services: list
290 """
291 def __init__(self, client, services):
292 """
293 @param client: A suds client.
294 @type client: L{Client}
295 @param services: A list of I{wsdl} services.
296 @type services: list
297 """
298 self.__client = client
299 self.__services = services
300
301 def __getattr__(self, name):
302 """
303 Request to access an attribute is forwarded to the
304 L{PortSelector} for either the I{first} service or the
305 I{default} service (when specified).
306 @param name: The name of a method.
307 @type name: str
308 @return: A L{PortSelector}.
309 @rtype: L{PortSelector}.
310 """
311 default = self.__ds()
312 if default is None:
313 port = self.__find(0)
314 else:
315 port = default
316 return getattr(port, name)
317
318 def __getitem__(self, name):
319 """
320 Provides selection of the I{service} by name (string) or
321 index (integer). In cases where only (1) service is defined
322 or a I{default} has been specified, the request is forwarded
323 to the L{PortSelector}.
324 @param name: The name (or index) of a service.
325 @type name: (int|str)
326 @return: A L{PortSelector} for the specified service.
327 @rtype: L{PortSelector}.
328 """
329 if len(self.__services) == 1:
330 port = self.__find(0)
331 return port[name]
332 default = self.__ds()

Callers 2

__init__Method · 0.85
cloneMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected