suds.mx package

Submodules

suds.mx.appender module

Provides appender classes for marshalling.

class suds.mx.appender.Appender(marshaller)

An appender used by the marshaller to append content. :ivar marshaller: A marshaller. :type marshaller: suds.mx.core.Core

append(parent, content)

Append the specified content to the parent. :param content: The content to append. :type content: Object

node(content)

Create and return an XML node that is qualified using the type. Also, make sure all referenced namespace prefixes are declared. :param content: The content for which processing has ended. :type content: Object :return: A new node. :rtype: Element

optional(content)

Get whether the specified content is optional. :param content: The content which to check. :type content: Content

resume(content)

Notify marshaller that appending this content has resumed. :param content: The content for which processing has been resumed. :type content: Object

setdefault(node, content)

Set the value of the node to a default value. :param node: A nil node. :type node: Element :param content: The content for which processing has ended. :type content: Object :return: The default.

setnil(node, content)

Set the value of the node to nill. :param node: A nil node. :type node: Element :param content: The content for which processing has ended. :type content: Object

suspend(content)

Notify marshaller that appending this content has suspended. :param content: The content for which processing has been suspended. :type content: Object

class suds.mx.appender.ContentAppender(marshaller)

Appender used to add content to marshalled objects. :ivar default: The default appender. :type default: Appender :ivar appenders: A table of appenders mapped by class. :type appenders: table

append(parent, content)

Select an appender and append the content to parent. :param parent: A parent node. :type parent: Element :param content: The content to append. :type content: Content

class suds.mx.appender.ElementAppender(marshaller)

Bases: suds.mx.appender.Appender

An appender for Element types.

append(parent, content)
class suds.mx.appender.ElementWrapper(content)

Bases: suds.sax.element.Element

Element wrapper.

str(indent=0)

Get a string representation of this XML fragment.

Parameters:indent (int) – The indent to be used in formatting the output.
Returns:A pretty string.
Return type:basestring
class suds.mx.appender.ListAppender(marshaller)

Bases: suds.mx.appender.Appender

A list/tuple appender.

append(parent, content)
class suds.mx.appender.Matcher(cls)

Appender matcher. :ivar cls: A class object. :type cls: classobj

class suds.mx.appender.NoneAppender(marshaller)

Bases: suds.mx.appender.Appender

An appender for None values.

append(parent, content)
class suds.mx.appender.ObjectAppender(marshaller)

Bases: suds.mx.appender.Appender

An Object appender.

append(parent, content)
class suds.mx.appender.PrimitiveAppender(marshaller)

Bases: suds.mx.appender.Appender

An appender for python primitive types.

append(parent, content)
class suds.mx.appender.PropertyAppender(marshaller)

Bases: suds.mx.appender.Appender

A Property appender.

append(parent, content)
class suds.mx.appender.TextAppender(marshaller)

Bases: suds.mx.appender.Appender

An appender for Text values.

append(parent, content)

suds.mx.basic module

Provides basic marshaller classes.

class suds.mx.basic.Basic

Bases: suds.mx.core.Core

A basic (untyped) marshaller.

process(value, tag=None)

Process (marshal) the tag with the specified value using the optional type information. :param value: The value (content) of the XML node. :type value: (:class:`Object`|any) :param tag: The (optional) tag name for the value. The default is

value.__class__.__name__
Returns:An xml node.
Return type:Element

suds.mx.core module

Provides marshaller core classes.

class suds.mx.core.Core

An abstract marshaller. This class implement the core functionality of the marshaller. :ivar appender: A content appender. :type appender: ContentAppender

append(parent, content)

Append the specified content to the parent. :param parent: The parent node to append to. :type parent: Element :param content: The content to append. :type content: Object

end(parent, content)

Appending this content has ended. :param parent: The parent node ending. :type parent: Element :param content: The content for which processing has ended. :type content: Content

node(content)

Create and return an XML node. :param content: Content information for the new node. :type content: Content :return: An element. :rtype: Element

optional(content)

Get whether the specified content is optional. :param content: The content which to check. :type content: Content

process(content)

Process (marshal) the tag with the specified value using the optional type information. :param content: The content to process. :type content: Object

reset()

Reset the marshaller.

resume(content)

Appending this content has resumed. :param content: The content for which processing has been resumed. :type content: Content

setdefault(node, content)

Set the value of the node to a default value. :param node: A nil node. :type node: Element :param content: The content to set the default value. :type content: Content :return: The default.

setnil(node, content)

Set the value of the node to nill. :param node: A nil node. :type node: Element :param content: The content to set nil. :type content: Content

start(content)

Appending this content has started. :param content: The content for which processing has started. :type content: Content :return: True to continue appending :rtype: boolean

suspend(content)

Appending this content has suspended. :param content: The content for which processing has been suspended. :type content: Content

suds.mx.encoded module

Provides encoded marshaller classes.

class suds.mx.encoded.Encoded(schema, xstq=True)

Bases: suds.mx.literal.Literal

A SOAP section (5) encoding marshaller. This marshaller supports rpc/encoded soap styles.

cast(content)

Cast the untyped list items found in content value. Each items contained in the list is checked for XSD type information. Items (values) that are untyped, are replaced with suds objects and type metadata is added. :param content: The content holding the collection. :type content: Content :return: self :rtype: Encoded

encode(node, content)
end(parent, content)
start(content)

suds.mx.literal module

Provides literal marshaller classes.

class suds.mx.literal.Literal(schema, xstq=True)

Bases: suds.mx.literal.Typed

A literal marshaller.

This marshaller is semi-typed as needed to support both document/literal and rpc/literal soap message styles.

class suds.mx.literal.Typed(schema, xstq=True)

Bases: suds.mx.core.Core

A typed marshaller.

This marshaller is semi-typed as needed to support both document/literal and rpc/literal SOAP message styles.

Variables:
encode(node, content)

Add (SOAP) encoding information if needed.

The encoding information is added only if the resolved type is derived by extension. Furthermore, the xsi:type value is qualified by namespace only if the content (tag) and referenced type are in different namespaces.

end(parent, content)

End processing the content.

Make sure the content ending matches the top of the resolver stack since for list processing we play games with the resolver stack.

node(content)

Create an XML node.

The XML node is namespace qualified as defined by the corresponding schema element.

optional(content)
ordering(type)

Attribute ordering defined in the specified XSD type information.

Parameters:type (SchemaObject) – XSD type object.
Returns:An ordered list of attribute names.
Return type:list
reset()
resume(content)

Resume processing list content.

To do this, we really need to simply push the ‘list’ content back onto the resolver stack.

setdefault(node, content)

Set the node to the default value specified by the XSD type.

setnil(node, content)

Set the ‘node’ nil only if the XSD type specifies that it is permitted.

skip(content)

Get whether to skip this content.

Should be skipped when the content is optional and value is either None or an empty list.

Parameters:content (Object) – Content to skip.
Returns:True if content is to be skipped.
Return type:bool
sort(content)

Sort suds object attributes.

The attributes are sorted based on the ordering defined in the XSD type information.

Parameters:content (Object) – Content to sort.
Returns:self
Return type:Typed
start(content)

Start marshalling the ‘content’ by ensuring that both the ‘content’ _and_ the resolver are primed with the XSD type information. The ‘content’ value is both translated and sorted based on the XSD type. Only values that are objects have their attributes sorted.

suspend(content)

Suspend to process list content.

Primarily, this involves popping the ‘list’ content off the resolver’s stack so its list items can be marshalled.

translate(content)

Translate using the XSD type information.

Python dict is translated to a suds object. Most importantly, primitive values are translated from python to XML types using the XSD type.

Parameters:content (Object) – Content to translate.
Returns:self
Return type:Typed

suds.mx.typer module

Provides XSD typing classes.

class suds.mx.typer.Typer

Provides XML node typing as either automatic or manual.

Variables:types – Class to XSD type mapping.
classmethod auto(node, value=None)

Automatically set the node’s xsi:type attribute based on either value’s or the node text’s class. When value is an unmapped class, the default type (xs:any) is set.

Parameters:
  • node (sax.element.Element) – XML node.
  • value (any) – Object that is or would be the node’s text.
Returns:

Specified node.

Return type:

sax.element.Element

classmethod genprefix(node, ns)

Generate a prefix.

Parameters:
  • node (sax.element.Element) – XML node on which the prefix will be used.
  • ns ((prefix, URI)) – Namespace needing a unique prefix.
Returns:

ns with a new prefix.

Return type:

(prefix, URI)

classmethod known(object)
classmethod manual(node, tval, ns=None)

Set the node’s xsi:type attribute based on either value’s or the node text’s class. Then adds the referenced prefix(s) to the node’s prefix mapping.

Parameters:
  • node (sax.element.Element) – XML node.
  • tval (str) – XSD schema type name.
  • ns ((prefix, URI)) – tval XML namespace.
Returns:

Specified node.

Return type:

sax.element.Element

types = {<type 'float'>: ('float', ('xs', 'http://www.w3.org/2001/XMLSchema')), <type 'int'>: ('int', ('xs', 'http://www.w3.org/2001/XMLSchema')), <type 'long'>: ('long', ('xs', 'http://www.w3.org/2001/XMLSchema')), <type 'str'>: ('string', ('xs', 'http://www.w3.org/2001/XMLSchema')), <type 'unicode'>: ('string', ('xs', 'http://www.w3.org/2001/XMLSchema')), <type 'bool'>: ('boolean', ('xs', 'http://www.w3.org/2001/XMLSchema')), <class 'suds.sax.text.Text'>: ('string', ('xs', 'http://www.w3.org/2001/XMLSchema'))}

Module contents

Provides modules containing classes to support marshalling to XML.

class suds.mx.Content(tag=None, value=None, **kwargs)

Bases: suds.sudsobject.Object

Marshaller content.

Variables:
  • tag – The content tag.
  • value – The content’s value.
extensions = ['type', 'real', 'ancestry', 'aty']