cdict (ClassDict) is a funny kind of dict that tries to return the values for the base classes of a key when the entry for the key is not found. It is not a generalized dictionary that can handle any type of key – it relies on spyne.model api to look for classes.
>>> from spyne.util.cdict import cdict
>>> class A(object):
... pass
...
>>> class B(A):
... pass
...
>>> class C(object):
... pass
...
>>> class D:
... pass
...
>>> d=cdict({A: "fun", object: "base"})
>>> print d[A]
fun
>>> print d
{<class '__main__.A'>: 'fun', <type 'object'>: 'base'}
>>> print d[B]
fun
>>> print d
{<class '__main__.A'>: 'fun', <class '__main__.B'>: 'fun', <type 'object'>: 'base'}
>>> print d[C]
base
>>> print d
{<class '__main__.A'>: 'fun', <class '__main__.B'>: 'fun', <class '__main__.C'>: 'base', <type 'object'>: 'base'}
>>> print d[D]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/plq/src/github/plq/spyne/src/spyne/util/cdict.py", line 77, in __getitem__
raise e
KeyError: <class __main__.D at 0x8d92c0>
>>>
This module contains the utility methods that convert an ElementTree hierarchy to python dicts and vice versa.
Takes a the dict whose value is either None or an instance of dict, odict or an iterable. The iterables can contain either other dicts/odicts or str/unicode instances.
Removes any namespace information form the given element recursively.
Takes an xml root element and returns the corresponding dict. The second argument is a pair of iterable type and the function used to add elements to the iterable. The xml attributes are ignored.
Converts a dictionary to an xml hiearchy. Just like a valid xml document, the dictionary must have a single element. The format of the child dictionaries is the same as dict_to_etree().
Takes an xml root element and returns the corresponding dict. The second argument is a pair of iterable type and the function used to add elements to the iterable. The xml attributes are ignored.
Contains functions that implement the most common protocol and transport combinations
Wraps services argument inside a PyramidApplication that uses Soap 1.1 for both input and output protocols.
Wraps services argument inside a WsgiApplication that uses Soap 1.1 for both input and output protocols.
DEPRECATED! Use wsgi_soap11_application() instead.
The spyne.util.xml module contains various Xml and Xml Schema related utility functions.
Returns an ElementTree representation of a spyne.model.complex.ComplexModel subclass.
Parameters: |
|
---|
Returns the schema documents in a dict whose keys are namespace prefixes and values are Element objects.
Parameters: | models – A list of spyne.model classes that will be represented in the schema. |
---|
Returns the validation schema object for the given models.
Parameters: | models – A list of spyne.model classes that will be represented in the schema. |
---|
Returns a native spyne.model.complex.ComplexModel child from an ElementTree representation of the same class.
Parameters: |
|
---|
This module contains a sort of an ordered dictionary implementation.
The spyne.util.oset package contains implementation of an ordered set that works on Python versions 2.4 through 2.7.