desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'translate (unwrap) using an optional wrapper function'
| def unwrap(self, d, item):
| nopt = (lambda x: x)
try:
md = d.__metadata__
pmd = getattr(md, '__print__', None)
if (pmd is None):
return item
wrappers = getattr(pmd, 'wrappers', {})
fn = wrappers.get(item[0], nopt)
return (item[0], fn(item[1]))
except:
pass
return ... |
'check metadata for excluded items'
| def exclude(self, d, item):
| try:
md = d.__metadata__
pmd = getattr(md, '__print__', None)
if (pmd is None):
return False
excludes = getattr(pmd, 'excludes', [])
return (item[0] in excludes)
except:
pass
return False
|
'Notification that a values was updated and the linkage
between the I{properties} contained with I{prev} need to
be relinked to the L{Properties} contained within the
I{next} value.'
| def updated(self, properties, prev, next):
| pass
|
'@param a: Property (A) to link.
@type a: L{Property}
@param b: Property (B) to link.
@type b: L{Property}'
| def __init__(self, a, b):
| pA = Endpoint(self, a)
pB = Endpoint(self, b)
self.endpoints = (pA, pB)
self.validate(a, b)
a.links.append(pB)
b.links.append(pA)
|
'Validate that the two properties may be linked.
@param pA: Endpoint (A) to link.
@type pA: L{Endpoint}
@param pB: Endpoint (B) to link.
@type pB: L{Endpoint}
@return: self
@rtype: L{Link}'
| def validate(self, pA, pB):
| if ((pA in pB.links) or (pB in pA.links)):
raise Exception, 'Already linked'
dA = pA.domains()
dB = pB.domains()
for d in dA:
if (d in dB):
raise Exception, ('Duplicate domain "%s" found' % d)
for d in dB:
if (d in dA):
raise Exception, ('D... |
'Teardown the link.
Removes endpoints from properties I{links} collection.
@return: self
@rtype: L{Link}'
| def teardown(self):
| (pA, pB) = self.endpoints
if (pA in pB.links):
pB.links.remove(pA)
if (pB in pA.links):
pA.links.remove(pB)
return self
|
'@param name: The property name.
@type name: str
@param classes: The (class) list of permitted values
@type classes: tuple
@param default: The default value.
@type default: any'
| def __init__(self, name, classes, default, linker=AutoLinker()):
| if (not isinstance(classes, (list, tuple))):
classes = (classes,)
self.name = name
self.classes = classes
self.default = default
self.linker = linker
|
'Convert the I{value} into the default when I{None}.
@param value: The proposed value.
@type value: any
@return: The I{default} when I{value} is I{None}, else I{value}.
@rtype: any'
| def nvl(self, value=None):
| if (value is None):
return self.default
else:
return value
|
'Validate the I{value} is of the correct class.
@param value: The value to validate.
@type value: any
@raise AttributeError: When I{value} is invalid.'
| def validate(self, value):
| if (value is None):
return
if (len(self.classes) and (not isinstance(value, self.classes))):
msg = ('"%s" must be: %s' % (self.name, self.classes))
raise AttributeError, msg
|
'@param domain: The property domain name.
@type domain: str
@param definitions: A table of property definitions.
@type definitions: {name: L{Definition}}
@param kwargs: A list of property name/values to set.
@type kwargs: dict'
| def __init__(self, domain, definitions, kwargs):
| self.definitions = {}
for d in definitions:
self.definitions[d.name] = d
self.domain = domain
self.links = []
self.defined = {}
self.modified = set()
self.prime()
self.update(kwargs)
|
'Get the definition for the property I{name}.
@param name: The property I{name} to find the definition for.
@type name: str
@return: The property definition
@rtype: L{Definition}
@raise AttributeError: On not found.'
| def definition(self, name):
| d = self.definitions.get(name)
if (d is None):
raise AttributeError(name)
return d
|
'Update the property values as specified by keyword/value.
@param other: An object to update from.
@type other: (dict|L{Properties})
@return: self
@rtype: L{Properties}'
| def update(self, other):
| if isinstance(other, Properties):
other = other.defined
for (n, v) in other.items():
self.set(n, v)
return self
|
'Get whether a property has never been set by I{name}.
@param name: A property name.
@type name: str
@return: True if never been set.
@rtype: bool'
| def notset(self, name):
| self.provider(name).__notset(name)
|
'Set the I{value} of a property by I{name}.
The value is validated against the definition and set
to the default when I{value} is None.
@param name: The property name.
@type name: str
@param value: The new property value.
@type value: any
@return: self
@rtype: L{Properties}'
| def set(self, name, value):
| self.provider(name).__set(name, value)
return self
|
'Unset a property by I{name}.
@param name: A property name.
@type name: str
@return: self
@rtype: L{Properties}'
| def unset(self, name):
| self.provider(name).__set(name, None)
return self
|
'Get the value of a property by I{name}.
@param name: The property name.
@type name: str
@param df: An optional value to be returned when the value
is not set
@type df: [1].
@return: The stored value, or I{df[0]} if not set.
@rtype: any'
| def get(self, name, *df):
| return self.provider(name).__get(name, *df)
|
'Link (associate) this object with anI{other} properties object
to create a network of properties. Links are bidirectional.
@param other: The object to link.
@type other: L{Properties}
@return: self
@rtype: L{Properties}'
| def link(self, other):
| Link(self, other)
return self
|
'Unlink (disassociate) the specified properties object.
@param others: The list object to unlink. Unspecified means unlink all.
@type others: [L{Properties},..]
@return: self
@rtype: L{Properties}'
| def unlink(self, *others):
| if (not len(others)):
others = self.links[:]
for p in self.links[:]:
if (p in others):
p.teardown()
return self
|
'Find the provider of the property by I{name}.
@param name: The property name.
@type name: str
@param history: A history of nodes checked to prevent
circular hunting.
@type history: [L{Properties},..]
@return: The provider when found. Otherwise, None (when nested)
and I{self} when not nested.
@rtype: L{Properties}'
| def provider(self, name, history=None):
| if (history is None):
history = []
history.append(self)
if (name in self.definitions):
return self
for x in self.links:
if (x in history):
continue
provider = x.provider(name, history)
if (provider is not None):
return provider
history.... |
'Get the set of I{all} property names.
@param history: A history of nodes checked to prevent
circular hunting.
@type history: [L{Properties},..]
@return: A set of property names.
@rtype: list'
| def keys(self, history=None):
| if (history is None):
history = []
history.append(self)
keys = set()
keys.update(self.definitions.keys())
for x in self.links:
if (x in history):
continue
keys.update(x.keys(history))
history.remove(self)
return keys
|
'Get the set of I{all} domain names.
@param history: A history of nodes checked to prevent
circular hunting.
@type history: [L{Properties},..]
@return: A set of domain names.
@rtype: list'
| def domains(self, history=None):
| if (history is None):
history = []
history.append(self)
domains = set()
domains.add(self.domain)
for x in self.links:
if (x in history):
continue
domains.update(x.domains(history))
history.remove(self)
return domains
|
'Prime the stored values based on default values
found in property definitions.
@return: self
@rtype: L{Properties}'
| def prime(self):
| for d in self.definitions.values():
self.defined[d.name] = d.default
return self
|
'Get the value of a property by I{name}.
@param name: The property name.
@type name: str
@param df: An optional value to be returned when the value
is not set
@type df: [1].
@return: The stored value, or I{df[0]} if not set.
@rtype: any'
| def get(self, name, *df):
| return self.properties.get(name, *df)
|
'Update the property values as specified by keyword/value.
@param kwargs: A list of property name/values to set.
@type kwargs: dict
@return: self
@rtype: L{Properties}'
| def update(self, **kwargs):
| return self.properties.update(**kwargs)
|
'Link (associate) this object with anI{other} properties object
to create a network of properties. Links are bidirectional.
@param other: The object to link.
@type other: L{Properties}
@return: self
@rtype: L{Properties}'
| def link(self, other):
| p = other.__pts__
return self.properties.link(p)
|
'Unlink (disassociate) the specified properties object.
@param other: The object to unlink.
@type other: L{Properties}
@return: self
@rtype: L{Properties}'
| def unlink(self, other):
| p = other.__pts__
return self.properties.unlink(p)
|
'Open a document at the specified url.
@param url: A document URL.
@type url: str
@return: A file pointer to the document.
@rtype: StringIO'
| def open(self, url):
| (protocol, location) = self.split(url)
if (protocol == self.protocol):
return self.find(location)
else:
return None
|
'Find the specified location in the store.
@param location: The I{location} part of a URL.
@type location: str
@return: An input stream to the document.
@rtype: StringIO'
| def find(self, location):
| try:
content = self.store[location]
return StringIO(content)
except:
reason = ('location "%s" not in document store' % location)
raise Exception, reason
|
'Split the url into I{protocol} and I{location}
@param url: A URL.
@param url: str
@return: (I{url}, I{location})
@rtype: tuple'
| def split(self, url):
| parts = url.split('://', 1)
if (len(parts) == 2):
return parts
else:
return (None, url)
|
''
| def __init__(self):
| Object.__init__(self)
self.mustUnderstand = True
self.tokens = []
self.signatures = []
self.references = []
self.keys = []
|
'Get xml representation of the object.
@return: The root node.
@rtype: L{Element}'
| def xml(self):
| root = Element('Security', ns=wssens)
root.set('mustUnderstand', str(self.mustUnderstand).lower())
for t in self.tokens:
root.append(t.xml())
return root
|
'@param username: A username.
@type username: str
@param password: A password.
@type password: str'
| def __init__(self, username=None, password=None):
| Token.__init__(self)
self.username = username
self.password = password
self.nonce = None
self.created = None
|
'Set I{nonce} which is arbitraty set of bytes to prevent
reply attacks.
@param text: The nonce text value.
Generated when I{None}.
@type text: str'
| def setnonce(self, text=None):
| if (text is None):
s = []
s.append(self.username)
s.append(self.password)
s.append(Token.sysdate())
m = md5()
m.update(':'.join(s))
self.nonce = m.hexdigest()
else:
self.nonce = text
|
'Set I{created}.
@param dt: The created date & time.
Set as datetime.utc() when I{None}.
@type dt: L{datetime}'
| def setcreated(self, dt=None):
| if (dt is None):
self.created = Token.utc()
else:
self.created = dt
|
'Get xml representation of the object.
@return: The root node.
@rtype: L{Element}'
| def xml(self):
| root = Element('UsernameToken', ns=wssens)
u = Element('Username', ns=wssens)
u.setText(self.username)
root.append(u)
p = Element('Password', ns=wssens)
p.setText(self.password)
root.append(p)
if (self.nonce is not None):
n = Element('Nonce', ns=wssens)
n.setText(self.non... |
'@param validity: The time in seconds.
@type validity: int'
| def __init__(self, validity=90):
| Token.__init__(self)
self.created = Token.utc()
self.expires = (self.created + timedelta(seconds=validity))
|
'Process the specified soap envelope body and replace I{multiref} node
references with the contents of the referenced node.
@param body: A soap envelope body node.
@type body: L{Element}
@return: The processed I{body}
@rtype: L{Element}'
| def process(self, body):
| self.nodes = []
self.catalog = {}
self.build_catalog(body)
self.update(body)
body.children = self.nodes
return body
|
'Update the specified I{node} by replacing the I{multiref} references with
the contents of the referenced nodes and remove the I{href} attribute.
@param node: A node to update.
@type node: L{Element}
@return: The updated node
@rtype: L{Element}'
| def update(self, node):
| self.replace_references(node)
for c in node.children:
self.update(c)
return node
|
'Replacing the I{multiref} references with the contents of the
referenced nodes and remove the I{href} attribute. Warning: since
the I{ref} is not cloned,
@param node: A node to update.
@type node: L{Element}'
| def replace_references(self, node):
| href = node.getAttribute('href')
if (href is None):
return
id = href.getValue()
ref = self.catalog.get(id)
if (ref is None):
log.error('soap multiref: %s, not-resolved', id)
return
node.append(ref.children)
node.setText(ref.getText())
for a in ref.attribu... |
'Create the I{catalog} of multiref nodes by id and the list of
non-multiref nodes.
@param body: A soap envelope body node.
@type body: L{Element}'
| def build_catalog(self, body):
| for child in body.children:
if self.soaproot(child):
self.nodes.append(child)
id = child.get('id')
if (id is None):
continue
key = ('#%s' % id)
self.catalog[key] = child
|
'Get whether the specified I{node} is a soap encoded root.
This is determined by examining @soapenc:root=\'1\'.
The node is considered to be a root when the attribute
is not specified.
@param node: A node to evaluate.
@type node: L{Element}
@return: True if a soap encoded root.
@rtype: bool'
| def soaproot(self, node):
| root = node.getAttribute('root', ns=soapenc)
if (root is None):
return True
else:
return (root.value == '1')
|
'@param wsdl: A wsdl.
@type wsdl: L{wsdl.Definitions}'
| def __init__(self, wsdl):
| self.wsdl = wsdl
self.multiref = MultiRef()
|
'Get the appropriate XML decoder.
@return: Either the (basic|typed) unmarshaller.
@rtype: L{UmxTyped}'
| def unmarshaller(self, typed=True):
| if typed:
return UmxTyped(self.schema())
else:
return UmxBasic()
|
'Get the appropriate XML encoder.
@return: An L{MxLiteral} marshaller.
@rtype: L{MxLiteral}'
| def marshaller(self):
| return MxLiteral(self.schema(), self.options().xstq)
|
'Get parameter definitions.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
@param method: A servic emethod.
@type method: I{service.Method}
@return: A collection of parameter definitions
@rtype: [I{pdef},..]'
| def param_defs(self, method):
| raise Exception, 'not implemented'
|
'Get the soap message for the specified method, args and soapheaders.
This is the entry point for creating the outbound soap message.
@param method: The method being invoked.
@type method: I{service.Method}
@param args: A list of args for the method invoked.
@type args: list
@param kwargs: Named (keyword) args for the ... | def get_message(self, method, args, kwargs):
| content = self.headercontent(method)
header = self.header(content)
content = self.bodycontent(method, args, kwargs)
body = self.body(content)
env = self.envelope(header, body)
if self.options().prefixes:
body.normalizePrefixes()
env.promotePrefixes()
else:
env.refitPr... |
'Process the I{reply} for the specified I{method} by sax parsing the I{reply}
and then unmarshalling into python object(s).
@param method: The name of the invoked method.
@type method: str
@param reply: The reply XML received after invoking the specified method.
@type reply: str
@return: The unmarshalled reply. The re... | def get_reply(self, method, reply):
| reply = self.replyfilter(reply)
sax = Parser()
replyroot = sax.parse(string=reply)
plugins = PluginContainer(self.options().plugins)
plugins.message.parsed(reply=replyroot)
soapenv = replyroot.getChild('Envelope')
soapenv.promotePrefixes()
soapbody = soapenv.getChild('Body')
self.det... |
'Detect I{hidden} soapenv:Fault element in the soap body.
@param body: The soap envelope body.
@type body: L{Element}
@raise WebFault: When found.'
| def detect_fault(self, body):
| fault = body.getChild('Fault', envns)
if (fault is None):
return
unmarshaller = self.unmarshaller(False)
p = unmarshaller.process(fault)
if self.options().faults:
raise WebFault(p, fault)
return self
|
'Construct a I{list} reply. This mehod is called when it has been detected
that the reply is a list.
@param rt: The return I{type}.
@type rt: L{suds.xsd.sxbase.SchemaObject}
@param nodes: A collection of XML nodes.
@type nodes: [L{Element},...]
@return: A list of I{unmarshalled} objects.
@rtype: [L{Object},...]'
| def replylist(self, rt, nodes):
| result = []
resolved = rt.resolve(nobuiltin=True)
unmarshaller = self.unmarshaller()
for node in nodes:
sobject = unmarshaller.process(node, resolved)
result.append(sobject)
return result
|
'Construct a I{composite} reply. This method is called when it has been
detected that the reply has multiple root nodes.
@param rtypes: A list of known return I{types}.
@type rtypes: [L{suds.xsd.sxbase.SchemaObject},...]
@param nodes: A collection of XML nodes.
@type nodes: [L{Element},...]
@return: The I{unmarshalled... | def replycomposite(self, rtypes, nodes):
| dictionary = {}
for rt in rtypes:
dictionary[rt.name] = rt
unmarshaller = self.unmarshaller()
composite = Factory.object('reply')
for node in nodes:
tag = node.name
rt = dictionary.get(tag, None)
if (rt is None):
if (node.get('id') is None):
... |
'Extract the fault from the specified soap reply. If I{faults} is True, an
exception is raised. Otherwise, the I{unmarshalled} fault L{Object} is
returned. This method is called when the server raises a I{web fault}.
@param reply: A soap reply message.
@type reply: str
@return: A fault object.
@rtype: tuple ( L{Elem... | def get_fault(self, reply):
| reply = self.replyfilter(reply)
sax = Parser()
faultroot = sax.parse(string=reply)
soapenv = faultroot.getChild('Envelope')
soapbody = soapenv.getChild('Body')
fault = soapbody.getChild('Fault')
unmarshaller = self.unmarshaller(False)
p = unmarshaller.process(fault)
if self.options()... |
'Builds a parameter for the specified I{method} using the parameter
definition (pdef) and the specified value (object).
@param method: A method name.
@type method: str
@param pdef: A parameter definition.
@type pdef: tuple: (I{name}, L{xsd.sxbase.SchemaObject})
@param object: The parameter value.
@type object: any
@ret... | def mkparam(self, method, pdef, object):
| marshaller = self.marshaller()
content = Content(tag=pdef[0], value=object, type=pdef[1], real=pdef[1].resolve())
return marshaller.process(content)
|
'Builds a soapheader for the specified I{method} using the header
definition (hdef) and the specified value (object).
@param method: A method name.
@type method: str
@param hdef: A header definition.
@type hdef: tuple: (I{name}, L{xsd.sxbase.SchemaObject})
@param object: The header value.
@type object: any
@return: The... | def mkheader(self, method, hdef, object):
| marshaller = self.marshaller()
if isinstance(object, (list, tuple)):
tags = []
for item in object:
tags.append(self.mkheader(method, hdef, item))
return tags
content = Content(tag=hdef[0], value=object, type=hdef[1])
return marshaller.process(content)
|
'Build the B{<Envelope/>} for an soap outbound message.
@param header: The soap message B{header}.
@type header: L{Element}
@param body: The soap message B{body}.
@type body: L{Element}
@return: The soap envelope containing the body and header.
@rtype: L{Element}'
| def envelope(self, header, body):
| env = Element('Envelope', ns=envns)
env.addPrefix(Namespace.xsins[0], Namespace.xsins[1])
env.append(header)
env.append(body)
return env
|
'Build the B{<Body/>} for an soap outbound message.
@param content: The header content.
@type content: L{Element}
@return: the soap body fragment.
@rtype: L{Element}'
| def header(self, content):
| header = Element('Header', ns=envns)
header.append(content)
return header
|
'Get the content for the soap I{body} node.
@param method: A service method.
@type method: I{service.Method}
@param args: method parameter values
@type args: list
@param kwargs: Named (keyword) args for the method invoked.
@type kwargs: dict
@return: The xml content for the <body/>
@rtype: [L{Element},..]'
| def bodycontent(self, method, args, kwargs):
| raise Exception, 'not implemented'
|
'Get the content for the soap I{Header} node.
@param method: A service method.
@type method: I{service.Method}
@return: The xml content for the <body/>
@rtype: [L{Element},..]'
| def headercontent(self, method):
| n = 0
content = []
wsse = self.options().wsse
if (wsse is not None):
content.append(wsse.xml())
headers = self.options().soapheaders
if (not isinstance(headers, (tuple, list, dict))):
headers = (headers,)
if (len(headers) == 0):
return content
pts = self.headpart_... |
'Get the reply body content.
@param method: A service method.
@type method: I{service.Method}
@param body: The soap body
@type body: L{Element}
@return: the body content
@rtype: [L{Element},...]'
| def replycontent(self, method, body):
| raise Exception, 'not implemented'
|
'Build the B{<Body/>} for an soap outbound message.
@param content: The body content.
@type content: L{Element}
@return: the soap body fragment.
@rtype: L{Element}'
| def body(self, content):
| body = Element('Body', ns=envns)
body.append(content)
return body
|
'Get a list of I{parameter definitions} (pdef) defined for the specified method.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
@param method: A service method.
@type method: I{service.Method}
@param input: Defines input/output message.
@type input: boolean
@return: A list of parameter definitions
@rtyp... | def bodypart_types(self, method, input=True):
| result = []
if input:
parts = method.soap.input.body.parts
else:
parts = method.soap.output.body.parts
for p in parts:
if (p.element is not None):
query = ElementQuery(p.element)
else:
query = TypeQuery(p.type)
pt = query.execute(self.schem... |
'Get a list of I{parameter definitions} (pdef) defined for the specified method.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
@param method: A service method.
@type method: I{service.Method}
@param input: Defines input/output message.
@type input: boolean
@return: A list of parameter definitions
@rtyp... | def headpart_types(self, method, input=True):
| result = []
if input:
headers = method.soap.input.headers
else:
headers = method.soap.output.headers
for header in headers:
part = header.part
if (part.element is not None):
query = ElementQuery(part.element)
else:
query = TypeQuery(part.ty... |
'Get the L{xsd.sxbase.SchemaObject} returned by the I{method}.
@param method: A service method.
@type method: I{service.Method}
@return: The name of the type return by the method.
@rtype: [I{rtype},..]'
| def returned_types(self, method):
| result = []
for rt in self.bodypart_types(method, input=False):
result.append(rt)
return result
|
'@param name: The part name.
@type name: str
@param resolved: The part type.
@type resolved: L{suds.xsd.sxbase.SchemaObject}'
| def __init__(self, name, resolved):
| root = Element('element', ns=Namespace.xsdns)
SchemaElement.__init__(self, resolved.schema, root)
self.__resolved = resolved
self.name = name
self.form_qualified = False
|
'Get the document root. For I{rpc/(literal|encoded)}, this is the
name of the method qualifed by the schema tns.
@param method: A service method.
@type method: I{service.Method}
@return: A root element.
@rtype: L{Element}'
| def method(self, method):
| ns = method.soap.input.body.namespace
if (ns[0] is None):
ns = ('ns0', ns[1])
method = Element(method.name, ns=ns)
return method
|
'Get the appropriate XML decoder.
@return: Either the (basic|typed) unmarshaller.
@rtype: L{UmxTyped}'
| def unmarshaller(self, typed=True):
| if typed:
return UmxEncoded(self.schema())
else:
return RPC.unmarshaller(self, typed)
|
'Get the document root. For I{document/literal}, this is the
name of the wrapper element qualifed by the schema tns.
@param wrapper: The method name.
@type wrapper: L{xsd.sxbase.SchemaObject}
@return: A root element.
@rtype: L{Element}'
| def document(self, wrapper):
| tag = wrapper[1].name
ns = wrapper[1].namespace('ns0')
d = Element(tag, ns=ns)
return d
|
'The ancestry contains a <choice/>
@param ancestry: A list of ancestors.
@type ancestry: list
@return: True if contains <choice/>
@rtype: boolean'
| def bychoice(self, ancestry):
| for x in ancestry:
if x.choice():
return True
return False
|
'Extract the I{items} from a suds object much like the
items() method works on I{dict}.
@param sobject: A suds object
@type sobject: L{Object}
@return: A list of items contained in I{sobject}.
@rtype: [(key, value),...]'
| @classmethod
def items(cls, sobject):
| return sudsobject.items(sobject)
|
'Convert a sudsobject into a dictionary.
@param sobject: A suds object
@type sobject: L{Object}
@return: A python dictionary containing the
items contained in I{sobject}.
@rtype: dict'
| @classmethod
def dict(cls, sobject):
| return sudsobject.asdict(sobject)
|
'Extract the metadata from a suds object.
@param sobject: A suds object
@type sobject: L{Object}
@return: The object\'s metadata
@rtype: L{sudsobject.Metadata}'
| @classmethod
def metadata(cls, sobject):
| return sobject.__metadata__
|
'@param url: The URL for the WSDL.
@type url: str
@param kwargs: keyword arguments.
@see: L{Options}'
| def __init__(self, url, **kwargs):
| options = Options()
options.transport = HttpAuthenticated()
self.options = options
self.set_options(**kwargs)
reader = DefinitionsReader(options, Definitions)
self.wsdl = reader.open(url)
plugins = PluginContainer(options.plugins)
plugins.init.initialized(wsdl=self.wsdl)
self.factory... |
'Set options.
@param kwargs: keyword arguments.
@see: L{Options}'
| def set_options(self, **kwargs):
| p = Unskin(self.options)
p.update(kwargs)
|
'Add I{static} mapping of an XML namespace prefix to a namespace.
This is useful for cases when a wsdl and referenced schemas make heavy
use of namespaces and those namespaces are subject to changed.
@param prefix: An XML namespace prefix.
@type prefix: str
@param uri: An XML namespace URI.
@type uri: str
@raise Except... | def add_prefix(self, prefix, uri):
| root = self.wsdl.root
mapped = root.resolvePrefix(prefix, None)
if (mapped is None):
root.addPrefix(prefix, uri)
return
if (mapped[1] != uri):
raise Exception(('"%s" already mapped as "%s"' % (prefix, mapped)))
|
'Get last sent I{soap} message.
@return: The last sent I{soap} message.
@rtype: L{Document}'
| def last_sent(self):
| return self.messages.get('tx')
|
'Get last received I{soap} message.
@return: The last received I{soap} message.
@rtype: L{Document}'
| def last_received(self):
| return self.messages.get('rx')
|
'Get a shallow clone of this object.
The clone only shares the WSDL. All other attributes are
unique to the cloned object including options.
@return: A shallow clone.
@rtype: L{Client}'
| def clone(self):
| class Uninitialized(Client, ):
def __init__(self):
pass
clone = Uninitialized()
clone.options = Options()
cp = Unskin(clone.options)
mp = Unskin(self.options)
cp.update(deepcopy(mp))
clone.wsdl = self.wsdl
clone.factory = self.factory
clone.service = ServiceSelect... |
'@param wsdl: A schema object.
@type wsdl: L{wsdl.Definitions}'
| def __init__(self, wsdl):
| self.wsdl = wsdl
self.resolver = PathResolver(wsdl)
self.builder = Builder(self.resolver)
|
'create a WSDL type by name
@param name: The name of a type defined in the WSDL.
@type name: str
@return: The requested object.
@rtype: L{Object}'
| def create(self, name):
| timer = metrics.Timer()
timer.start()
type = self.resolver.find(name)
if (type is None):
raise TypeNotFound(name)
if type.enum():
result = InstFactory.object(name)
for (e, a) in type.children():
setattr(result, e.name, e.name)
else:
try:
re... |
'Set the path separator.
@param ps: The new path separator.
@type ps: char'
| def separator(self, ps):
| self.resolver = PathResolver(self.wsdl, ps)
|
'@param client: A suds client.
@type client: L{Client}
@param services: A list of I{wsdl} services.
@type services: list'
| def __init__(self, client, services):
| self.__client = client
self.__services = services
|
'Request to access an attribute is forwarded to the
L{PortSelector} for either the I{first} service or the
I{default} service (when specified).
@param name: The name of a method.
@type name: str
@return: A L{PortSelector}.
@rtype: L{PortSelector}.'
| def __getattr__(self, name):
| default = self.__ds()
if (default is None):
port = self.__find(0)
else:
port = default
return getattr(port, name)
|
'Provides selection of the I{service} by name (string) or
index (integer). In cases where only (1) service is defined
or a I{default} has been specified, the request is forwarded
to the L{PortSelector}.
@param name: The name (or index) of a service.
@type name: (int|str)
@return: A L{PortSelector} for the specified se... | def __getitem__(self, name):
| if (len(self.__services) == 1):
port = self.__find(0)
return port[name]
default = self.__ds()
if (default is not None):
port = default
return port[name]
return self.__find(name)
|
'Find a I{service} by name (string) or index (integer).
@param name: The name (or index) of a service.
@type name: (int|str)
@return: A L{PortSelector} for the found service.
@rtype: L{PortSelector}.'
| def __find(self, name):
| service = None
if (not len(self.__services)):
raise Exception, 'No services defined'
if isinstance(name, int):
try:
service = self.__services[name]
name = service.name
except IndexError:
raise ServiceNotFound, ('at [%d]' % name)
else:
... |
'Get the I{default} service if defined in the I{options}.
@return: A L{PortSelector} for the I{default} service.
@rtype: L{PortSelector}.'
| def __ds(self):
| ds = self.__client.options.service
if (ds is None):
return None
else:
return self.__find(ds)
|
'@param client: A suds client.
@type client: L{Client}
@param ports: A list of I{service} ports.
@type ports: list
@param qn: The name of the service.
@type qn: str'
| def __init__(self, client, ports, qn):
| self.__client = client
self.__ports = ports
self.__qn = qn
|
'Request to access an attribute is forwarded to the
L{MethodSelector} for either the I{first} port or the
I{default} port (when specified).
@param name: The name of a method.
@type name: str
@return: A L{MethodSelector}.
@rtype: L{MethodSelector}.'
| def __getattr__(self, name):
| default = self.__dp()
if (default is None):
m = self.__find(0)
else:
m = default
return getattr(m, name)
|
'Provides selection of the I{port} by name (string) or
index (integer). In cases where only (1) port is defined
or a I{default} has been specified, the request is forwarded
to the L{MethodSelector}.
@param name: The name (or index) of a port.
@type name: (int|str)
@return: A L{MethodSelector} for the specified port.
@... | def __getitem__(self, name):
| default = self.__dp()
if (default is None):
return self.__find(name)
else:
return default
|
'Find a I{port} by name (string) or index (integer).
@param name: The name (or index) of a port.
@type name: (int|str)
@return: A L{MethodSelector} for the found port.
@rtype: L{MethodSelector}.'
| def __find(self, name):
| port = None
if (not len(self.__ports)):
raise Exception, ('No ports defined: %s' % self.__qn)
if isinstance(name, int):
qn = ('%s[%d]' % (self.__qn, name))
try:
port = self.__ports[name]
except IndexError:
raise PortNotFound, qn
else:
... |
'Get the I{default} port if defined in the I{options}.
@return: A L{MethodSelector} for the I{default} port.
@rtype: L{MethodSelector}.'
| def __dp(self):
| dp = self.__client.options.port
if (dp is None):
return None
else:
return self.__find(dp)
|
'@param client: A suds client.
@type client: L{Client}
@param methods: A dictionary of methods.
@type methods: dict
@param qn: The I{qualified} name of the port.
@type qn: str'
| def __init__(self, client, methods, qn):
| self.__client = client
self.__methods = methods
self.__qn = qn
|
'Get a method by name and return it in an I{execution wrapper}.
@param name: The name of a method.
@type name: str
@return: An I{execution wrapper} for the specified method name.
@rtype: L{Method}'
| def __getattr__(self, name):
| return self[name]
|
'Get a method by name and return it in an I{execution wrapper}.
@param name: The name of a method.
@type name: str
@return: An I{execution wrapper} for the specified method name.
@rtype: L{Method}'
| def __getitem__(self, name):
| m = self.__methods.get(name)
if (m is None):
qn = '.'.join((self.__qn, name))
raise MethodNotFound, qn
return Method(self.__client, m)
|
'@param client: A client object.
@type client: L{Client}
@param method: A I{raw} method.
@type I{raw} Method.'
| def __init__(self, client, method):
| self.client = client
self.method = method
|
'Invoke the method.'
| def __call__(self, *args, **kwargs):
| clientclass = self.clientclass(kwargs)
client = clientclass(self.client, self.method)
if (not self.faults()):
try:
return client.invoke(args, kwargs)
except WebFault as e:
return (500, e)
else:
return client.invoke(args, kwargs)
|
'get faults option'
| def faults(self):
| return self.client.options.faults
|
'get soap client class'
| def clientclass(self, kwargs):
| if SimClient.simulation(kwargs):
return SimClient
else:
return SoapClient
|
'@param client: A suds client.
@type client: L{Client}
@param method: A target method.
@type method: L{Method}'
| def __init__(self, client, method):
| self.client = client
self.method = method
self.options = client.options
self.cookiejar = CookieJar()
|
'Send the required soap message to invoke the specified method
@param args: A list of args for the method invoked.
@type args: list
@param kwargs: Named (keyword) args for the method invoked.
@type kwargs: dict
@return: The result of the method invocation.
@rtype: I{builtin}|I{subclass of} L{Object}'
| def invoke(self, args, kwargs):
| timer = metrics.Timer()
timer.start()
result = None
binding = self.method.binding.input
soapenv = binding.get_message(self.method, args, kwargs)
timer.stop()
metrics.log.debug("message for '%s' created: %s", self.method.name, timer)
timer.start()
result = self.send(soapen... |
'Send soap message.
@param soapenv: A soap envelope to send.
@type soapenv: L{Document}
@return: The reply to the sent message.
@rtype: I{builtin} or I{subclass of} L{Object}'
| def send(self, soapenv):
| result = None
location = self.location()
binding = self.method.binding.input
transport = self.options.transport
retxml = self.options.retxml
prettyxml = self.options.prettyxml
log.debug('sending to (%s)\nmessage:\n%s', location, soapenv)
try:
self.last_sent(soapenv)
... |
'Get http headers or the http/https request.
@return: A dictionary of header/values.
@rtype: dict'
| def headers(self):
| action = self.method.soap.action
stock = {'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': action}
result = dict(stock, **self.options.headers)
log.debug('headers = %s', result)
return result
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.