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

Method cast

suds/mx/encoded.py:95–134  ·  view source on GitHub ↗

Cast the I{untyped} list items found in content I{value}. Each items contained in the list is checked for XSD type information. Items (values) that are I{untyped}, are replaced with suds objects and type I{metadata} is added. @param content: The content holdi

(self, content)

Source from the content-addressed store, hash-verified

93 Typer.manual(node, name, ns)
94
95 def cast(self, content):
96 """
97 Cast the I{untyped} list items found in content I{value}.
98 Each items contained in the list is checked for XSD type information.
99 Items (values) that are I{untyped}, are replaced with suds objects and
100 type I{metadata} is added.
101 @param content: The content holding the collection.
102 @type content: L{Content}
103 @return: self
104 @rtype: L{Encoded}
105 """
106 aty = content.aty[1]
107 resolved = content.type.resolve()
108 array = Factory.object(resolved.name)
109 array.item = []
110 query = TypeQuery(aty)
111 ref = query.execute(self.schema)
112 if ref is None:
113 raise TypeNotFound(qref)
114 for x in content.value:
115 if isinstance(x, (list, tuple)):
116 array.item.append(x)
117 continue
118 if isinstance(x, Object):
119 md = x.__metadata__
120 md.sxtype = ref
121 array.item.append(x)
122 continue
123 if isinstance(x, dict):
124 x = Factory.object(ref.name, x)
125 md = x.__metadata__
126 md.sxtype = ref
127 array.item.append(x)
128 continue
129 x = Factory.property(ref.name, x)
130 md = x.__metadata__
131 md.sxtype = ref
132 array.item.append(x)
133 content.value = array
134 return self

Callers 1

startMethod · 0.95

Calls 7

executeMethod · 0.95
TypeQueryClass · 0.90
TypeNotFoundClass · 0.85
objectMethod · 0.80
propertyMethod · 0.80
resolveMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected