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)
| 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 |